bidirectional_RNN icon indicating copy to clipboard operation
bidirectional_RNN copied to clipboard

imdb_birnn.py example error

Open stray-leone opened this issue 9 years ago • 6 comments

When I run imdb_birnn.py first time, I got the error as below. Isn't Transform() working?

$ python imdb_birnn.py
Using gpu device 0: GeForce GTX 770
Loading data...
20000 train sequences
5000 test sequences
Pad sequences (samples x time)
train_X shape: (20000, 100)
test_X shape: (5000, 100)
Build model...
Traceback (most recent call last):
  File "imdb_birnn.py", line 64, in <module>
    model.add(Dense(word_vec_len, 100, activation='relu'))
  File "/usr/local/lib/python2.7/dist-packages/keras/layers/containers.py", line 37, in add
    self.layers[-1].set_previous(self.layers[-2])
  File "/usr/local/lib/python2.7/dist-packages/keras/layers/core.py", line 33, in set_previous
    str(self.input_ndim) + " but previous layer has output_shape " + str(layer.output_shape)
AssertionError: Incompatible shapes: layer expected input with ndim=2 but previous layer has output_shape (None, None, 256)

stray-leone avatar Oct 14 '15 00:10 stray-leone

Are you using the latest commit? I have fixed some default argument value, most probably you have to set return_sequences=True for LSTM argument

On 14 Oct, 2015, at 8:27 am, stray-leone [email protected] wrote:

When I run imdb_birnn.py first time, I got the error as below. Isn't Transform() working?

$ python imdb_birnn.py Using gpu device 0: GeForce GTX 770 Loading data... 20000 train sequences 5000 test sequences Pad sequences (samples x time) train_X shape: (20000, 100) test_X shape: (5000, 100) Build model... Traceback (most recent call last): File "imdb_birnn.py", line 64, in model.add(Dense(word_vec_len, 100, activation='relu')) File "/usr/local/lib/python2.7/dist-packages/keras/layers/containers.py", line 37, in add self.layers[-1].set_previous(self.layers[-2]) File "/usr/local/lib/python2.7/dist-packages/keras/layers/core.py", line 33, in set_previous str(self.input_ndim) + " but previous layer has output_shape " + str(layer.output_shape) AssertionError: Incompatible shapes: layer expected input with ndim=2 but previous layer has output_shape (None, None, 256) — Reply to this email directly or view it on GitHub.

hycis avatar Oct 14 '15 02:10 hycis

I am sure that I am using latest commit. I didn't modify anything. I just clone repo and run 'python imdb_birnn.py'

Can you give me a way of debugging Transform() function ?? Because I want to check the output dimension of Transform()

stray-leone avatar Oct 14 '15 02:10 stray-leone

keras has restructured the code beyond my recognition. In order to use the birnn, will require the previous version. It's more of some major restructuring done to keras recently that make it not as flexible. Try mozi if you have time, I will be adding birnn to mozi also. Also I will try to see what i can do make birnn compatible with the new keras.

hycis avatar Oct 14 '15 09:10 hycis

I think you should look keras old release https://github.com/fchollet/keras/releases/tag/0.1.3 current release adds input_shape and output_shape property and checks its sanity before get_output, while for transform, the input_shape and output_shape is only calculated at the get_output step. Which means current keras version don't have the flexibility to incorporate Transform.

hycis avatar Oct 14 '15 15:10 hycis

Thank you for your kind advice I will try this way

2015년 10월 15일 (목) 오전 12:29, Alex Woo [email protected]님이 작성:

I think you should look keras old release https://github.com/fchollet/keras/releases/tag/0.1.3 current release adds input_shape and output_shape property and checks its sanity before get_output, while for transform, the input_shape and output_shape is only calculated at the get_output step. Which means current keras version don't have the flexibility to incorporate Transform.

— Reply to this email directly or view it on GitHub https://github.com/hycis/bidirectional_RNN/issues/9#issuecomment-148086572 .

stray-leone avatar Oct 16 '15 10:10 stray-leone

And I also download mozi and try it. When you add bidirectional rnn to mozi or new keras. I will try.

stray-leone avatar Oct 17 '15 23:10 stray-leone