Closed MilesZhao closed 6 years ago
error info in detail.
Traceback (most recent call last): File "/home/is-lab/.local/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py", line 671, in _call_cpp_shape_fn_impl input_tensors_as_shapes, status) File "/usr/lib/python3.5/contextlib.py", line 66, in exit next(self.gen) File "/home/is-lab/.local/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status pywrap_tensorflow.TF_GetCode(status)) tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape must be rank 2 but is rank 3 for 'Masking/MatMul' (op: 'MatMul') with input shapes: [10,16], [1,10,1].
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tf_orginal_CapsNet.py", line 345, in
This is due to the using of the tf.squeeze
in this line:
self.masked_v = tf.matmul(tf.squeeze(self.caps2), tf.reshape(self.Y, (batch_size, 10, 1)), transpose_a=True)
But, who will set batch size to 1? If you really want it, explicitly squeeze
on caps2 in the last dim, like this:
self.masked_v = tf.multiply(tf.squeeze(self.caps2, axis=-1), tf.reshape(self.Y, (-1, 10, 1)))
When I set batch as 1, there is a value error when building the graph. I think it was caused the this line of code.