Reputation: 3
ValueError: Can not squeeze dim[1], expected a dimension of 1, got 14 for 'tower_0/joint_embedding/Squeeze' (op: 'Squeeze') with input shapes: [16,14,14,512]
Traceback (most recent call last):
File "train_image_text.py", line 244, in <module>
tf.app.run()
File "/net/per920a/export/das14a/satoh-lab/kajalk/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "train_image_text.py", line 240, in main
train_models.train()
File "/net/per610a/export/das18a/satoh-lab/kajalk/new_exp_cm/CMPL/train_models.py", line 240, in train
input_seqs_splits[k], input_masks_splits[k])
File "/net/per610a/export/das18a/satoh-lab/kajalk/new_exp_cm/CMPL/train_models.py", line 76, in _tower_loss
patch_embeddings = build_patch_joint_embeddings(patch_features, scope='patch_joint_embedding')
File "/net/per610a/export/das18a/satoh-lab/kajalk/new_exp_cm/CMPL/modules.py", line 228, in build_patch_joint_embeddings
joint_embeddings = tf.squeeze(joint_embeddings,[1]) # batch_size * patch_size *feature_size
File "/net/per920a/export/das14a/satoh-lab/kajalk/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 2394, in squeeze
return gen_array_ops._squeeze(input, axis, name)
File "/net/per920a/export/das14a/satoh-lab/kajalk/anaconda2/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 5202, in _squeeze
"Squeeze", input=input, squeeze_dims=squeeze_dims, name=name)
File "/net/per920a/export/das14a/satoh-lab/kajalk/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/net/per920a/export/das14a/satoh-lab/kajalk/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2958, in create_op
set_shapes_for_outputs(ret)
File "/net/per920a/export/das14a/satoh-lab/kajalk/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2209, in set_shapes_for_outputs
shapes = shape_func(op)
File "/net/per920a/export/das14a/satoh-lab/kajalk/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2159, in call_with_requiring
return call_cpp_shape_fn(op, require_shape_fn=True)
File "/net/per920a/export/das14a/satoh-lab/kajalk/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 627, in call_cpp_shape_fn
require_shape_fn)
File "/net/per920a/export/das14a/satoh-lab/kajalk/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 691, in _call_cpp_shape_fn_impl
raise ValueError(err.message)
ValueError: Can not squeeze dim[1], expected a dimension of 1, got 14 for 'tower_0/joint_embedding/Squeeze' (op: 'Squeeze') with input shapes: [16,14,14,512].
Upvotes: 0
Views: 62
Reputation: 406
The error which you've got is when you wrongly specify squeeze dimension for your tensor. Please see example below:
x = tf.get_variable('x', [2,3,4])
x = tf.squeeze(x)
In above example x
will have the same shape as at the begining. Squeeze does nothing because the tensor doesn't contain shape 1 on any axis.
Let's see the second example:
x = tf.get_variable('x', [2,3,4])
x = tf.squeeze(x, axis=1)
Now the tensorflow throws an exception because you are trying to squeeze dimension of with different shape than 1
Can not squeeze dim[1], expected a dimension of 1, got 2
So you should check if your tensor has shape 1
on the given axis or if you would like to sqeeze all axis with shape 1
then please don't specify axis in tf.sqeeze
function
Upvotes: 1