Closed 4fur4 closed 8 years ago
Add dtype='int' to the arguments of add_input
Great, it worked. Thanks a lot. Shouldnt this be the default behaviour of the dtype for that method?
What a coincidence! I just figured it out this exact problem. dtype='int'
seems to be an unusual argument in keras. Why do we have this argument here?
Hi all,
Im trying to use a multi-input version of the imdb_cnn
https://github.com/fchollet/keras/blob/master/examples/imdb_cnn.py
following the Graph example in the literature I have this
However, when running it I get the following error
graph.compile(optimizer='rmsprop', loss={'output': 'mean_absolute_error'}) File "build/bdist.linux-x86_64/egg/keras/models.py", line 1045, in compile File "build/bdist.linux-x86_64/egg/keras/layers/core.py", line 532, in get_output File "build/bdist.linux-x86_64/egg/keras/layers/core.py", line 962, in get_output File "build/bdist.linux-x86_64/egg/keras/layers/core.py", line 173, in get_input File "build/bdist.linux-x86_64/egg/keras/layers/core.py", line 834, in get_output File "build/bdist.linux-x86_64/egg/keras/layers/core.py", line 173, in get_input File "build/bdist.linux-x86_64/egg/keras/layers/convolutional.py", line 375, in get_output File "build/bdist.linux-x86_64/egg/keras/layers/core.py", line 173, in get_input File "build/bdist.linux-x86_64/egg/keras/layers/convolutional.py", line 140, in get_output File "build/bdist.linux-x86_64/egg/keras/layers/core.py", line 173, in get_input File "build/bdist.linux-x86_64/egg/keras/layers/embeddings.py", line 100, in get_output File "build/bdist.linux-x86_64/egg/keras/backend/theano_backend.py", line 130, in gather File "/usr/local/lib/python2.7/dist-packages/theano/sandbox/cuda/var.py", line 162, in getitem return _operators.getitem(self, _args) File "/usr/local/lib/python2.7/dist-packages/theano/tensor/var.py", line 502, in getitem return self.take(args[axis], axis) File "/usr/local/lib/python2.7/dist-packages/theano/tensor/var.py", line 534, in take return theano.tensor.subtensor.take(self, indices, axis, mode) File "/usr/local/lib/python2.7/dist-packages/theano/tensor/subtensor.py", line 2386, in take return take(a, indices.flatten(), axis, mode).reshape(shape, ndim) File "/usr/local/lib/python2.7/dist-packages/theano/tensor/subtensor.py", line 2364, in take return advanced_subtensor1(a, indices) File "/usr/local/lib/python2.7/dist-packages/theano/gof/op.py", line 600, in call node = self.make_node(_inputs, **kwargs) File "/usr/local/lib/python2.7/dist-packages/theano/tensor/subtensor.py", line 1687, in make_node raise TypeError('index must be integers') TypeError: index must be integers
I guess the Embedding layer doesnt like much what the input layer is giving to it.
The hyperparameters and the dimensions of X_train/X2_train, X_test/X2_test are the same as in the imdb_cnn.py class. In my case y_train, y_test contain float values (for regression) but using a sequential model with single input works fine so I guess this is not the issue.
Any ideas on how to solve this?