udibr / headlines

Automatically generate headlines to short articles
MIT License
525 stars 150 forks source link

ValueError: Shape (?, 50, 512) must have rank 2 #11

Closed xtr33me closed 8 years ago

xtr33me commented 8 years ago

Hey Udibr! I am receiving the above error when training and was wondering if you have ran into this by chance or perhaps have an idea as to what may be causing it. First off, I am using the latest Tensorflow. I found someone getting the same issue in another project at the link below that he said he wasnt seeing in Theano but he was seeing in Tensorflow: https://github.com/jocicmarko/ultrasound-nerve-segmentation/commit/e1433994f38cbaeb44e261169bc5dc6885474787

I figured I would post here just in-case you had any more insight into what might be happening. I have pasted the error output below. I am still tracing this down, but if you have any ideas, please let me know. Thanks!

H: mathematical formula for beer goggles D: british scientists discover the exact equation so-called beer goggles Traceback (most recent call last): File "train.py", line 267, in model.add(SimpleContext()) File "/usr/local/lib/python2.7/site-packages/keras/models.py", line 307, in add output_tensor = layer(self.outputs[0]) File "/usr/local/lib/python2.7/site-packages/keras/engine/topology.py", line 511, in call self.add_inbound_node(inbound_layers, node_indices, tensor_indices) File "/usr/local/lib/python2.7/site-packages/keras/engine/topology.py", line 569, in add_inbound_node Node.create_node(self, inbound_layers, node_indices, tensor_indices) File "/usr/local/lib/python2.7/site-packages/keras/engine/topology.py", line 150, in create_node output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0])) File "/usr/local/lib/python2.7/site-packages/keras/layers/core.py", line 455, in call return self.function(x, **arguments) File "train.py", line 227, in simple_context desc, head = X[:,:maxlend], X[:,maxlend:] File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 167, in _SliceHelper sliced = slice(tensor, indices, sizes) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 217, in slice return gen_array_ops.slice(input, begin, size, name=name) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 1318, in _slice name=name) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/op_def_library.py", line 655, in apply_op op_def=op_def) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2156, in create_op set_shapes_for_outputs(ret) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1612, in set_shapes_for_outputs shapes = shape_func(op) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 865, in _SliceShape input_shape.assert_has_rank(ndims) File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/tensor_shape.py", line 605, in assert_has_rank raise ValueError("Shape %s must have rank %d" % (self, rank)) ValueError: Shape (?, 50, 512) must have rank 2

udibr commented 8 years ago

It Looks like the code you are using is old! just do git pull and run again...

This is the source of the problem: the following desc, head = X[:,:maxlend], X[:,maxlend:] should be replaced with desc, head = X[:,:maxlend,:], X[:,maxlend:,:]

I think that Theano understands that you also want the 3rd dimension (as in numpy) but TF does not. Please let me know if it works and I will push the update

xtr33me commented 8 years ago

Dang that was fast. That was indeed the issue. Thanks for the help. I was a bit confused as to how I had old code, but I see the issue was in a converter I wrote that was converting from the notebook to a .py file. It seems I am having a bug in that processing that wasn't throwing an error on my side. Sorry for wasting your time and thanks again.