seq2seq
seq2seq copied to clipboard
AttentionSeq2Seq error
The example given in the readme is not working. Any ideas?
model = AttentionSeq2Seq(input_dim=5, input_length=7, hidden_dim=10, output_length=8, output_dim=20, depth=4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user1/src/seq2seq/seq2seq/models.py", line 283, in AttentionSeq2Seq
decoded = decoder(encoded)
File "/home/user1/src/recurrentshop/recurrentshop/engine.py", line 566, in __call__
self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
File "/home/user1/src/keras/keras/engine/topology.py", line 635, in add_inbound_node
Node.create_node(self, inbound_layers, node_indices, tensor_indices)
File "/home/user1/src/keras/keras/engine/topology.py", line 166, in create_node
output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
File "/home/user1/src/recurrentshop/recurrentshop/engine.py", line 320, in call
initial_states = self.get_initial_states(x)
File "/home/user1/src/recurrentshop/recurrentshop/engine.py", line 388, in get_initial_states
input = layer._step(input, layer_initial_states)[0]
File "/home/user1/src/recurrentshop/recurrentshop/engine.py", line 116, in _step
return self.step(*args)
File "/home/user1/src/seq2seq/seq2seq/cells.py", line 85, in step
x = K.batch_dot(energy, H, axes=(1, 1))
File "/home/user1/src/keras/keras/backend/tensorflow_backend.py", line 874, in batch_dot
raise ValueError('Invalid dimensions for batch_dot: ', ndim(x), ndim(y))
ValueError: ('Invalid dimensions for batch_dot: ', 2, 3)
I also find this problem.
same problem. I add an embedding layer before the AttentionSeq2seq layer. Here is my code:
model = Sequential() model.add(Embedding(max_features, embedding_vector_dim, input_length=max_doc_length)) model.add(AttentionSeq2Seq(input_length=max_doc_length, input_dim=embedding_vector_dim, hidden_dim=hidden_dim, output_length=max_doc_length, output_dim=embedding_vector_dim)) model.compile(loss='mse', optimizer='adam')
Same problem... Here is the code. from seq2seq.models import AttentionSeq2Seq
samples = 30 input_length = 30 input_dim = 30 output_length = 30 output_dim = 30
x = np.random.random((samples, input_length, input_dim))
y = np.random.random((samples, output_length, output_dim)) models = AttentionSeq2Seq(output_dim=output_dim, output_length=output_length, input_shape=(input_length, input_dim))
For me attentionSeq2Seq works with theano Backend but not with tensorflow backend. Reason is that batch_dot in tensorflow must be used with at least 3d Tensors https://github.com/fchollet/keras/issues/4588. You can change backend in ~/.keras/keras.json. Maybe someone can provide a fix for tensorflow backend.
@smodlich Thanks! Theano backend works. Problem solved.
Is this able to be fixed?