farizrahman4u / seq2seq

Sequence to Sequence Learning with Keras
GNU General Public License v2.0
3.17k stars 845 forks source link

Having a really strange error while importing seq2seq models #221

Open kimmo1019 opened 6 years ago

kimmo1019 commented 6 years ago

I have successfully installed recurrentshop and seq2seq as the github pages suggest. Then I try to run a demo like the following

import seq2seq
from seq2seq.models import SimpleSeq2Seq
model = SimpleSeq2Seq(input_dim=5, hidden_dim=10, output_length=8, output_dim=8)

I got an unexpected error

AttributeError                            Traceback (most recent call last)
<ipython-input-5-31d6acbcb683> in <module>()
      1 import seq2seq
      2 from seq2seq.models import SimpleSeq2Seq
----> 3 model = SimpleSeq2Seq(input_dim=5, hidden_dim=10, output_length=8, output_dim=8)
      4 #model.compile(loss='mse', optimizer='rmsprop')

/opt/anaconda2/lib/python2.7/site-packages/seq2seq/models.pyc in SimpleSeq2Seq(output_dim, output_length, hidden_dim, input_shape, batch_size, batch_input_shape, input_dim, input_length, depth, dropout, unroll, stateful)
     78 
     79     _input = Input(batch_shape=shape)
---> 80     x = encoder(_input)
     81     output = decoder(x)
     82     return Model(_input, output)

/opt/anaconda2/lib/python2.7/site-packages/recurrentshop-1.0.0-py2.7.egg/recurrentshop/engine.pyc in __call__(self, inputs, initial_state, initial_readout, ground_truth, **kwargs)
    494                         kwargs['mask'] = previous_mask
    495             input_shape = _collect_input_shape(inputs)
--> 496             output = self.call(inputs, **kwargs)
    497             output_mask = self.compute_mask(inputs[0], previous_mask)
    498             output_shape = self.compute_output_shape(input_shape[0])

/opt/anaconda2/lib/python2.7/site-packages/recurrentshop-1.0.0-py2.7.egg/recurrentshop/engine.pyc in call(self, inputs, initial_state, initial_readout, ground_truth, mask, training)
    583                              'the time dimension by passing a `shape` '
    584                              'or `batch_shape` argument to your Input layer.')
--> 585         preprocessed_input = self.preprocess_input(inputs, training=None)
    586         constants = self.get_constants(inputs, training=None)
    587         if self.decode:

/opt/anaconda2/lib/python2.7/site-packages/recurrentshop-1.0.0-py2.7.egg/recurrentshop/engine.pyc in preprocess_input(self, input, training)
    657 
    658     def preprocess_input(self, input, training=None):
--> 659         if self._preprocess_function is None:
    660             return input
    661         return self._preprocess_function(input)

AttributeError: 'RecurrentSequential' object has no attribute '_preprocess_function'

This is really strange and has bothered me for days. It seems that no one occurred the same error like me. This error seems to originate in recurrentshop package. Could anyone help me solve this problem, thks a lot. BTW, my environment: centos7.0 + python 2.7 + keras 2.0.8 + tensorflow 1.0.1

unnir commented 6 years ago

have the same issue

walmsley commented 6 years ago

temporary workaround: install old version of recurrentshop: pip install git+https://github.com/datalogai/recurrentshop.git@f5a1d126dd579c1eefe7c7caaa4ccd8867ee09d4

kunkun1230 commented 4 years ago

Similar issue. However my error is


model = SimpleSeq2Seq(input_dim=5, hidden_dim=10, output_length=8, output_dim=8)
Traceback (most recent call last):

File "", line 1, in model = SimpleSeq2Seq(input_dim=5, hidden_dim=10, output_length=8, output_dim=8)

File "D:\Program\Anaconda\lib\site-packages\seq2seq-1.0.0-py3.7.egg\seq2seq\models.py", line 58, in SimpleSeq2Seq encoder = RecurrentSequential(unroll=unroll, stateful=stateful)

File "D:\Program\Anaconda\lib\site-packages\recurrentshop-1.0.0-py3.7.egg\recurrentshop\engine.py", line 888, in init self.readout_activation = activations.get(readout_activation)

NameError: name 'activations' is not defined


Anyone knows how to solve this issue?
cui-xiaoang96 commented 4 years ago

Similar issue. However my error is

model = SimpleSeq2Seq(input_dim=5, hidden_dim=10, output_length=8, output_dim=8)
Traceback (most recent call last):

  File "<ipython-input-8-5fa801e7cd93>", line 1, in <module>
    model = SimpleSeq2Seq(input_dim=5, hidden_dim=10, output_length=8, output_dim=8)

  File "D:\Program\Anaconda\lib\site-packages\seq2seq-1.0.0-py3.7.egg\seq2seq\models.py", line 58, in SimpleSeq2Seq
    encoder = RecurrentSequential(unroll=unroll, stateful=stateful)

  File "D:\Program\Anaconda\lib\site-packages\recurrentshop-1.0.0-py3.7.egg\recurrentshop\engine.py", line 888, in __init__
    self.readout_activation = activations.get(readout_activation)

NameError: name 'activations' is not defined

Anyone knows how to solve this issue?

the same error I met

cui-xiaoang96 commented 4 years ago

Similar issue. However my error is

model = SimpleSeq2Seq(input_dim=5, hidden_dim=10, output_length=8, output_dim=8)
Traceback (most recent call last):

  File "<ipython-input-8-5fa801e7cd93>", line 1, in <module>
    model = SimpleSeq2Seq(input_dim=5, hidden_dim=10, output_length=8, output_dim=8)

  File "D:\Program\Anaconda\lib\site-packages\seq2seq-1.0.0-py3.7.egg\seq2seq\models.py", line 58, in SimpleSeq2Seq
    encoder = RecurrentSequential(unroll=unroll, stateful=stateful)

  File "D:\Program\Anaconda\lib\site-packages\recurrentshop-1.0.0-py3.7.egg\recurrentshop\engine.py", line 888, in __init__
    self.readout_activation = activations.get(readout_activation)

NameError: name 'activations' is not defined

Anyone knows how to solve this issue?

did you have solve it? please share it with me. thanks very much.

cui-xiaoang96 commented 4 years ago

Similar issue. However my error is

model = SimpleSeq2Seq(input_dim=5, hidden_dim=10, output_length=8, output_dim=8)
Traceback (most recent call last):

  File "<ipython-input-8-5fa801e7cd93>", line 1, in <module>
    model = SimpleSeq2Seq(input_dim=5, hidden_dim=10, output_length=8, output_dim=8)

  File "D:\Program\Anaconda\lib\site-packages\seq2seq-1.0.0-py3.7.egg\seq2seq\models.py", line 58, in SimpleSeq2Seq
    encoder = RecurrentSequential(unroll=unroll, stateful=stateful)

  File "D:\Program\Anaconda\lib\site-packages\recurrentshop-1.0.0-py3.7.egg\recurrentshop\engine.py", line 888, in __init__
    self.readout_activation = activations.get(readout_activation)

NameError: name 'activations' is not defined

Anyone knows how to solve this issue?

I have done it. you must add the sentence "from keras import activations" to advanced_cell.py, basic_cells.py, cells.py and engine.py. and my program works after doing that.