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

when import seq2seq have an error:cannot import name '_collect_previous_mask' #250

Open
njustzsm opened this issue Jun 15, 2018 · 3 comments

Comments

@njustzsm
Copy link

can you tell me how to fix it? it occur in:
from keras.engine.topology import Node, _collect_previous_mask, _collect_input_shape

@chenjindong
Copy link

I have the same problem. Who can help me?

@ty5491003
Copy link

ty5491003 commented Jun 28, 2018

l just solved this problem: i repalced my keras version from 2.2.0 to 2.0.0 , use "pip install --upgrade keras==2.0.0" , you can try it!
But now i have an new issue when i run the SimpleSeq2Seq:
Traceback (most recent call last): File "C:/Users/ty/PycharmProjects/conala-baseline-master/preproc/seq2seq_model.py", line 4, in <module> model = SimpleSeq2Seq(input_dim=5, hidden_dim=10, output_length=8, output_dim=8) File "C:\Users\ty\AppData\Local\Programs\Python\Python35\lib\site-packages\seq2seq-1.0.0-py3.5.egg\seq2seq\models.py", line 81, in SimpleSeq2Seq File "C:\Users\ty\AppData\Local\Programs\Python\Python35\lib\site-packages\recurrentshop-1.0.0-py3.5.egg\recurrentshop\engine.py", line 476, in __call__ File "C:\Users\ty\AppData\Local\Programs\Python\Python35\lib\site-packages\recurrentshop-1.0.0-py3.5.egg\recurrentshop\engine.py", line 1022, in build File "C:\Users\ty\AppData\Local\Programs\Python\Python35\lib\site-packages\keras\engine\topology.py", line 545, in __call__ output = self.call(inputs, **kwargs) File "C:\Users\ty\AppData\Local\Programs\Python\Python35\lib\site-packages\keras\layers\core.py", line 112, in call return output UnboundLocalError: local variable 'output' referenced before assignment

@HelloWorld-9527
Copy link

HelloWorld-9527 commented Jun 30, 2018

I also meet this problem, and I try to find this two as the function of python from Internet.
I am a fresh of keras and tensorflow, so I can't fully understand what it mean.
Althought it worked, but I meet another problem: AttributeError: '_OptionalInputPlaceHolder' object has no attribute 'inbound_nodes'

def _collect_input_shape(input_tensors): """Collects the output shape(s) of a list of Keras tensors. Arguments: input_tensors: list of input tensors (or single input tensor). Returns: List of shape tuples (or single tuple), one tuple per input. """ input_tensors = _to_list(input_tensors) shapes = [] for x in input_tensors: shapes.append(K.int_shape(x)) if len(shapes) == 1: return shapes[0] return shapes

from tensorflow.python.util import nest def _collect_previous_mask(input_tensors): """Retrieves the output mask(s) of the previous node. Arguments: input_tensors: A tensor or list of tensors. Returns: A mask tensor or list of mask tensors. """ input_tensors = nest.flatten(input_tensors) masks = [] for x in input_tensors: if hasattr(x, '_keras_mask'): mask = x._keras_mask # pylint: disable=protected-access masks.append(mask) else: masks.append(None) if len(masks) == 1: return masks[0] return masks
I don't know why :there is not line feeds when insert code

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

4 participants