dennybritz / rnn-tutorial-rnnlm

Recurrent Neural Network Tutorial, Part 2 - Implementing a RNN in Python and Theano
Apache License 2.0
895 stars 468 forks source link

Large error when using the genrate sentence method at the end #22

Open mherath opened 6 years ago

mherath commented 6 years ago

Hi there,

Thank you for taking your time to code and present it all in your tutorial. I've enjoyed trying them out so far. However I ran into this rather massive error when I tried to run the generate_sentence method in the portion of the tutorial where you generate words. The error is as follows (bear with me here, it is rather long):

Traceback (most recent call last): File "RNN.py", line 325, in sent = generate_sentence(model) File "RNN.py", line 306, in generate_sentence next_word_probs = model.forward_propagation(new_sentence) File "/home/mahesh/miniconda2/lib/python2.7/site-packages/theano/compile/function_module.py", line 917, in call storage_map=getattr(self.fn, 'storage_map', None)) File "/home/mahesh/miniconda2/lib/python2.7/site-packages/theano/gof/link.py", line 325, in raise_with_op reraise(exc_type, exc_value, exc_trace) File "/home/mahesh/miniconda2/lib/python2.7/site-packages/theano/compile/function_module.py", line 903, in call self.fn() if output_subset is None else\ File "/home/mahesh/miniconda2/lib/python2.7/site-packages/theano/scan_module/scan_op.py", line 963, in rval r = p(n, [x[0] for x in i], o) File "/home/mahesh/miniconda2/lib/python2.7/site-packages/theano/scan_module/scan_op.py", line 952, in p self, node) File "theano/scan_module/scan_perform.pyx", line 405, in theano.scan_module.scan_perform.perform (/home/mahesh/.theano/compiledir_Linux-3.17-fc21.x86_64-x86_64-with-fedora-21-Twenty_One-x86_64-2.7.13-64/scan_perform/mod.cpp:4606) File "/home/mahesh/miniconda2/lib/python2.7/site-packages/theano/gof/link.py", line 325, in raise_with_op reraise(exc_type, exc_value, exc_trace) File "theano/scan_module/scan_perform.pyx", line 397, in theano.scan_module.scan_perform.perform (/home/mahesh/.theano/compiledir_Linux-3.17-fc21.x86_64-x86_64-with-fedora-21-Twenty_One-x86_64-2.7.13-64/scan_perform/mod.cpp:4490) ValueError: Shape mismatch: A.shape[1] != x.shape[0] Apply node that caused the error: CGemv{no_inplace}(Subtensor{::, int32}.0, TensorConstant{1.0}, W_copy, <TensorType(float64, vector)>, TensorConstant{1.0}) Toposort index: 2 Inputs types: [TensorType(float64, vector), TensorType(float64, scalar), TensorType(float64, matrix), TensorType(float64, vector), TensorType(float64, scalar)] Inputs shapes: [(50,), (), (50, 50), (100,), ()] Inputs strides: [(64000,), (), (400, 8), (8,), ()] Inputs values: ['not shown', array(1.0), 'not shown', 'not shown', array(1.0)] Outputs clients: [[Elemwise{tanh,no_inplace}(CGemv{no_inplace}.0)]]

HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'. HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node. Apply node that caused the error: forall_inplace,cpu,scan_fn}(Shape_i{0}.0, Subtensor{int64:int64:int8}.0, IncSubtensor{InplaceSet;:int64:}.0, Shape_i{0}.0, V, U, W) Toposort index: 7 Inputs types: [TensorType(int64, scalar), TensorType(int32, vector), TensorType(float64, matrix), TensorType(int64, scalar), TensorType(float64, matrix), TensorType(float64, matrix), TensorType(float64, matrix)] Inputs shapes: [(), (1,), (1, 100), (), (8000, 50), (50, 8000), (50, 50)] Inputs strides: [(), (4,), (800, 8), (), (400, 8), (64000, 8), (400, 8)] Inputs values: [array(1), array([0], dtype=int32), 'not shown', array(1), 'not shown', 'not shown', 'not shown'] Outputs clients: [[], ['output']]

HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'. HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.

I can't quite figure out what the issue is over here. I would be grateful for any help you can give me in resolving this issue. I would love to get this code working in its entireity :)

thanks,

Mahesh