Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when import seq2seq #121

Closed
ay2456 opened this issue Nov 1, 2016 · 8 comments
Closed

Error when import seq2seq #121

ay2456 opened this issue Nov 1, 2016 · 8 comments

Comments

@ay2456
Copy link

ay2456 commented Nov 1, 2016

Hello,

I got this error when I tried to import seq2seq:

import seq2seq
Using TensorFlow backend.
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/site-packages/seq2seq/init.py", line 1, in
from .cells import *
File "/usr/local/lib/python2.7/site-packages/seq2seq/cells.py", line 1, in
from recurrentshop import RNNCell, LSTMCell, weight
File "/usr/local/lib/python2.7/site-packages/recurrentshop/init.py", line 1, in
from .engine import RNNCell, RecurrentContainer, weight
File "/usr/local/lib/python2.7/site-packages/recurrentshop/engine.py", line 32, in
_backend = getattr(K, K.backend() + '_backend')
AttributeError: 'module' object has no attribute 'backend'

What should I do?

BTW,
I just installed the latest version of seq2seq and recurrentshop.
The following are the version of my python and keras.

python: 2.7.11
keras: 1.0.5

Thanks!

@farizrahman4u
Copy link
Owner

Update keras.

@ay2456
Copy link
Author

ay2456 commented Nov 2, 2016

Hi,

I updated my keras version and I can import seq2seq now.
However, my previous code is not working.

Previously, I have:
model = Seq2seq(batch_input_shape=(1, n_input_steps, n_input), hidden_dim=n_hidden, output_length=n_output_steps, output_dim=n_output, dropout=dropout, stateful=True, peek=True)

Since there is no Seq2seq now, I changed to Seq2Seq:
model = Seq2Seq(batch_input_shape=(1, n_input_steps, n_input), hidden_dim=n_hidden, output_length=n_output_steps, output_dim=n_output, dropout=dropout, stateful=True, peek=True)

But it returns an error:

File "/usr/local/lib/python2.7/site-packages/seq2seq/models.py", line 171, in Seq2Seq
encoded_seq = encoder(encoded_seq)
File "/usr/local/lib/python2.7/site-packages/keras/engine/topology.py", line 514, 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 572, 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 149, 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/recurrentshop/engine.py", line 309, in call
last_output_0, outputs_0, states_0, updates = rnn(self.step, x, initial_states, go_backwards=self.go_backwards, mask=mask, unroll=unroll, input_length=input_shape[1])
File "/usr/local/lib/python2.7/site-packages/recurrentshop/engine.py", line 51, in
rnn = lambda _args, *_kwargs: list(K.rnn(_args, *_kwargs)) + [[]]
File "/usr/local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 1206, in rnn
state = tf.concat(1, states)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 463, in concat
name=name)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 315, in _concat
values=values, name=name)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/op_def_library.py", line 704, in apply_op
op_def=op_def)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2262, in create_op
set_shapes_for_outputs(ret)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1702, in set_shapes_for_outputs
shapes = shape_func(op)
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 505, in _ConcatShape
value_shape.ndims)
ValueError: concat_dim is out of range (values rank = 1)

What should I do?

Thanks!

@farizrahman4u
Copy link
Owner

Use unroll=True option with tf backend. This has to be fixed on Keras side.

@viswanath57
Copy link

Hi,

While importing seq2seq module, getting the following error

In [2]: import seq2seq

ImportError Traceback (most recent call last)
in ()
----> 1 import seq2seq

/home/viswanath/seq2seq/seq2seq/init.py in ()
----> 1 from .cells import *
2 from .models import *

/home/viswanath/seq2seq/seq2seq/cells.py in ()
----> 1 from recurrentshop import RNNCell, LSTMCell, weight
2 from keras import backend as K
3 import numpy as np
4
5

ImportError: cannot import name weight

@viswanath57
Copy link

It seems like most recent recurrentshop module does not have weight function

@PraveenKumarCSE
Copy link

Same issue for me also. The weight function removed from recurrentshop lib.

@dmitriydligach
Copy link

Same issue here. Is there a workaround?

@farizrahman4u
Copy link
Owner

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants