Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalidargument #103

Open
akshadaas opened this issue Mar 18, 2020 · 2 comments
Open

invalidargument #103

akshadaas opened this issue Mar 18, 2020 · 2 comments

Comments

@akshadaas
Copy link

akshadaas commented Mar 18, 2020

i got the following error.
InvalidArgumentError Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in _create_c_op(graph, node_def, inputs, control_inputs)
1658 try:
-> 1659 c_op = c_api.TF_FinishOperation(op_desc)
1660 except errors.InvalidArgumentError as e:

InvalidArgumentError: Dimensions must be equal, but are 16 and 752 for 'decoder_1/dense_4/MatMul' (op: 'MatMul') with input shapes: [?,16], [752,512].

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)
in
57 class_mode='categorical', shuffle=True)
58
---> 59 train_model, eval_model, manipulate_model = CapsNet(input_shape=(28, 28, 3), n_class=47, routings=3)
60 # compile the model
61

in CapsNet(input_shape, n_class, routings)
27 decoder.add(layers.Dense(np.prod(input_shape), activation='sigmoid'))
28 decoder.add(layers.Reshape(target_shape=input_shape, name='out_recon'))
---> 29 print(decoder(masked_by_y))
30
31 # Models for training and evaluation (prediction)

~/anaconda3/lib/python3.7/site-packages/keras/engine/topology.py in call(self, inputs, **kwargs)
601
602 # Actually call the layer, collecting output(s), mask(s), and shape(s).
--> 603 output = self.call(inputs, **kwargs)
604 output_mask = self.compute_mask(inputs, previous_mask)
605

~/anaconda3/lib/python3.7/site-packages/keras/models.py in call(self, inputs, mask)
544 if not self.built:
545 self.build()
--> 546 return self.model.call(inputs, mask)
547
548 def build(self, input_shape=None):

~/anaconda3/lib/python3.7/site-packages/keras/engine/topology.py in call(self, inputs, mask)
2059 return self._output_tensor_cache[cache_key]
2060 else:
-> 2061 output_tensors, _, _ = self.run_internal_graph(inputs, masks)
2062 return output_tensors
2063

~/anaconda3/lib/python3.7/site-packages/keras/engine/topology.py in run_internal_graph(self, inputs, masks)
2210 if 'mask' not in kwargs:
2211 kwargs['mask'] = computed_mask
-> 2212 output_tensors = _to_list(layer.call(computed_tensor, **kwargs))
2213 output_masks = _to_list(layer.compute_mask(computed_tensor,
2214 computed_mask))

~/anaconda3/lib/python3.7/site-packages/keras/layers/core.py in call(self, inputs)
841
842 def call(self, inputs):
--> 843 output = K.dot(inputs, self.kernel)
844 if self.use_bias:
845 output = K.bias_add(output, self.bias)

~/anaconda3/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py in dot(x, y)
1050 out = tf.sparse_tensor_dense_matmul(x, y)
1051 else:
-> 1052 out = tf.matmul(x, y)
1053 return out
1054

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/math_ops.py in matmul(a, b, transpose_a, transpose_b, adjoint_a, adjoint_b, a_is_sparse, b_is_sparse, name)
2453 else:
2454 return gen_math_ops.mat_mul(
-> 2455 a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
2456
2457

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/ops/gen_math_ops.py in mat_mul(a, b, transpose_a, transpose_b, name)
5331 _, _, _op = _op_def_lib._apply_op_helper(
5332 "MatMul", a=a, b=b, transpose_a=transpose_a, transpose_b=transpose_b,
-> 5333 name=name)
5334 _result = _op.outputs[:]
5335 _inputs_flat = _op.inputs

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py in _apply_op_helper(self, op_type_name, name, **keywords)
786 op = g.create_op(op_type_name, inputs, output_types, name=scope,
787 input_types=input_types, attrs=attr_protos,
--> 788 op_def=op_def)
789 return output_structure, op_def.is_stateful, op
790

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py in new_func(*args, **kwargs)
505 'in a future version' if date is None else ('after %s' % date),
506 instructions)
--> 507 return func(*args, **kwargs)
508
509 doc = _add_deprecated_arg_notice_to_docstring(

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in create_op(failed resolving arguments)
3298 input_types=input_types,
3299 original_op=self._default_original_op,
-> 3300 op_def=op_def)
3301 self._create_op_helper(ret, compute_device=compute_device)
3302 return ret

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in init(self, node_def, g, inputs, output_types, control_inputs, input_types, original_op, op_def)
1821 op_def, inputs, node_def.attr)
1822 self._c_op = _create_c_op(self._graph, node_def, grouped_inputs,
-> 1823 control_input_ops)
1824
1825 # Initialize self._outputs.

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in _create_c_op(graph, node_def, inputs, control_inputs)
1660 except errors.InvalidArgumentError as e:
1661 # Convert to ValueError for backwards compatibility.
-> 1662 raise ValueError(str(e))
1663
1664 return c_op

ValueError: Dimensions must be equal, but are 16 and 752 for 'decoder_1/dense_4/MatMul' (op: 'MatMul') with input shapes: [?,16], [752,512].

@XifengGuo can you please look into it?

@akshadaas
Copy link
Author

what is the tensorflow version?

@XifengGuo
Copy link
Owner

@akshadaas Please use the versions of keras and tensorflow specified in README.md
Also, you can try this branch for Tensorflow 2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants