The two tensors I'm feeding into tf.nn.conv1d()
are x
and kernel
with sizes [16,512,32] and [1,1,32] respectively. I've been able to run this code on my local machine, but I get an error when running it on a remote cluster.
I get a Value Error stating that the dimensions must be equal. The message shows the resulting shapes for x
and kernel
as [16,1,512,32] and [1,1,1,32] respectively.
tensorflow-gpu-1.14.0
and python-3.6
. The wrapper is shown below that I'm calling within my code: filter_size =1
input_dim = 32
output_dim = 32
def conv1d_linear(self,x, filter_size,input_dim,output_dim,stride=1,name = 'conv1d_linear'):
with tf.variable_scope(name):
# Conv1D wrapper, with bias and no activation
print(x)
kernel = tf.get_variable('kernel', shape = [filter_size, input_dim, output_dim],initializer=tf.contrib.layers.xavier_initializer())
print(kernel)
bias = tf.get_variable('bias', shape = [output_dim],initializer=tf.contrib.layers.xavier_initializer())
x = tf.nn.conv1d(x, kernel, stride=stride, padding='SAME')
x = tf.nn.bias_add(x, bias)
x = tf.contrib.layers.batch_norm(x)
return x
Error Message
Using TensorFlow backend.
Tensorflow Version: 1.14.0
Building model...
Tensor("stfnet/resstack0/stft_pool0/Relu:0", shape=(16, 512, 32), dtype=float32, device=/device:GPU:0)
<tf.Variable 'stfnet/resstack1/init_conv_lin0/kernel:0' shape=(1, 1, 32) dtype=float32_ref>
Traceback (most recent call last):
File "/nv/hp20/nblinn6/.conda/envs/mytfenv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1659, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 32 and 1 for 'stfnet/resstack1/init_conv_lin0/conv1d/Conv2D' (op: 'Conv2D') with input shapes: [16,1,512,32], [1,1,1,32].
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/nv/hp20/nblinn6/data/MODID_mystfresnet6_final_PB_2gpu.py", line 529, in <module>
mymodel.train_init()
File "/nv/hp20/nblinn6/data/MODID_mystfresnet6_final_PB_2gpu.py", line 413, in train_init
self.logits_train = self.ModIDNet(self.batch_feature[0:int(self.gpu_batch_size)],self.tau,self.keep_rate,train = True,reuse = reuse_flg,name = 'stfnet')
File "/nv/hp20/nblinn6/data/MODID_mystfresnet6_final_PB_2gpu.py", line 340, in ModIDNet
x = self.resstack(x,tau,self.sensor_axis,self.maps[1],reuse = reuse,series_size = 512,name = 'resstack1')
File "/nv/hp20/nblinn6/data/MODID_mystfresnet6_final_PB_2gpu.py", line 310, in resstack
x1 = self.conv1d_linear(x,1,map_in,map_out, name = 'init_conv_lin0')
File "/nv/hp20/nblinn6/data/MODID_mystfresnet6_final_PB_2gpu.py", line 302, in conv1d_linear
x = tf.nn.conv1d(x, kernel, stride=stride, padding='SAME')
File "/nv/hp20/nblinn6/.conda/envs/mytfenv/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 574, in new_func
return func(*args, **kwargs)
File "/nv/hp20/nblinn6/.conda/envs/mytfenv/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 574, in new_func
return func(*args, **kwargs)
File "/nv/hp20/nblinn6/.conda/envs/mytfenv/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py", line 3482, in conv1d
data_format=data_format)
File "/nv/hp20/nblinn6/.conda/envs/mytfenv/lib/python3.6/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 1026, in conv2d
data_format=data_format, dilations=dilations, name=name)
File "/nv/hp20/nblinn6/.conda/envs/mytfenv/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "/nv/hp20/nblinn6/.conda/envs/mytfenv/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/nv/hp20/nblinn6/.conda/envs/mytfenv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3300, in create_op
op_def=op_def)
File "/nv/hp20/nblinn6/.conda/envs/mytfenv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1823, in __init__
control_input_ops)
File "/nv/hp20/nblinn6/.conda/envs/mytfenv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1662, in _create_c_op
raise ValueError(str(e))
ValueError: Dimensions must be equal, but are 32 and 1 for 'stfnet/resstack1/init_conv_lin0/conv1d/Conv2D' (op: 'Conv2D') with input shapes: [16,1,512,32], [1,1,1,32].
I reinstalled the version of tensorflow-gpu==1.14.0
just as a troubleshooting step and it seems to be working now. Unsure what the original issue was.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.