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

ValueError: Shapes (2, 35, 1) and () are incompatible #2

Open
yang12313 opened this issue Apr 5, 2019 · 0 comments
Open

ValueError: Shapes (2, 35, 1) and () are incompatible #2

yang12313 opened this issue Apr 5, 2019 · 0 comments

Comments

@yang12313
Copy link

yang12313 commented Apr 5, 2019

I got this error when I run the code:


ValueError Traceback (most recent call last)
in
271
272 if name == "main":
--> 273 test_RNN()

in test_RNN()
259 model = RNN_Model(config)
260 start_time = time.time()
--> 261 stats = model.train(verbose=True)
262 print('Training time: {}'.format(time.time() - start_time))
263

in train(self, verbose)
216 print('epoch %d'%epoch)
217 if epoch==0:
--> 218 train_acc, val_acc, loss_history, val_loss = self.run_epoch(new_model=True)
219 else:
220 train_acc, val_acc, loss_history, val_loss = self.run_epoch()

in run_epoch(self, new_model, verbose)
176 break
177 tree = self.train_data[step]
--> 178 logits = self.inference(tree)
179 labels = [l for l in tree.labels if l!=2]
180 loss = self.loss(logits, labels)

in inference(self, tree, predict_only_root)
38
39 def inference(self, tree, predict_only_root=False):
---> 40 node_tensors = self.add_model(tree.root)
41 if predict_only_root:
42 node_tensors = node_tensors[tree.root][0]

in add_model(self, node)
81 curr_node_tensor = [curr_node_vec, curr_node_mat]
82 else:
---> 83 node_tensors.update(self.add_model(node.left))
84 node_tensors.update(self.add_model(node.right))
85 tmp = tf.concat(0,

in add_model(self, node)
82 else:
83 node_tensors.update(self.add_model(node.left))
---> 84 node_tensors.update(self.add_model(node.right))
85 tmp = tf.concat(0,
86 [tf.matmul(

in add_model(self, node)
81 curr_node_tensor = [curr_node_vec, curr_node_mat]
82 else:
---> 83 node_tensors.update(self.add_model(node.left))
84 node_tensors.update(self.add_model(node.right))
85 tmp = tf.concat(0,

in add_model(self, node)
82 else:
83 node_tensors.update(self.add_model(node.left))
---> 84 node_tensors.update(self.add_model(node.right))
85 tmp = tf.concat(0,
86 [tf.matmul(

in add_model(self, node)
81 curr_node_tensor = [curr_node_vec, curr_node_mat]
82 else:
---> 83 node_tensors.update(self.add_model(node.left))
84 node_tensors.update(self.add_model(node.right))
85 tmp = tf.concat(0,

in add_model(self, node)
90 tf.matmul(
91 node_tensors[node.left][1],
---> 92 node_tensors[node.right][0]
93 )
94 ])

E:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\util\dispatch.py in wrapper(*args, **kwargs)
178 """Call target, and fall back on dispatchers if there is a TypeError."""
179 try:
--> 180 return target(*args, **kwargs)
181 except (TypeError, ValueError):
182 # Note: convert_to_eager_tensor currently raises a ValueError, not a

E:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py in concat(values, axis, name)
1252 axis, name="concat_dim",
1253 dtype=dtypes.int32).get_shape().assert_is_compatible_with(
-> 1254 tensor_shape.scalar())
1255 return identity(values[0], name=scope)
1256 return gen_array_ops.concat_v2(values=values, axis=axis, name=name)

E:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\tensor_shape.py in assert_is_compatible_with(self, other)
1021 """
1022 if not self.is_compatible_with(other):
-> 1023 raise ValueError("Shapes %s and %s are incompatible" % (self, other))
1024
1025 def most_specific_compatible_shape(self, other):

ValueError: Shapes (2, 35, 1) and () are incompatible

### I ran your script on Jupyter and python 3.
Could you tell me how to fix it?

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

1 participant