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

Import errors with tensorflow version 0.12.1 #1

Closed
mads14 opened this issue Feb 4, 2017 · 4 comments
Closed

Import errors with tensorflow version 0.12.1 #1

mads14 opened this issue Feb 4, 2017 · 4 comments

Comments

@mads14
Copy link

mads14 commented Feb 4, 2017

Hi,

I just cloned your repo and downloaded tensorflow version 0.12.1. I am trying to run your example code. I am getting errors on the imports:

Traceback (most recent call last):
File "main.py", line 5, in
from trainer import Trainer
File ".../pointer-network-tensorflow/trainer.py", line 7, in
from model import Model
File ".../pointer-network-tensorflow/model.py", line 4, in
from layers import *
File ".../pointer-network-tensorflow/layers.py", line 7, in
LSTMCell = rnn.LSTMCell
AttributeError: 'module' object has no attribute 'LSTMCell'.

From looking at the tensorflow docs it seems that LSTMCell is now located at:
tf.nn.rnn_cell.STMCell. I changed the code to read: LSTMCell = tf.nn.rnn_cell.LSTMCell and made a similar change for the next line of layers.py: MultiRNNCell = tf.nn.rnn_cell.MultiRNNCell.

I'm now getting a similar error on the seq2seq line, and can't figure out how to fix it:
Traceback (most recent call last):
File "main.py", line 5, in
from trainer import Trainer
File ".../pointer-network-tensorflow/trainer.py", line 7, in
from model import Model
File ".../pointer-network-tensorflow/model.py", line 4, in
from layers import *
File ".../pointer-network-tensorflow/layers.py", line 9, in
dynamic_rnn_decoder = seq2seq.dynamic_rnn_decoder
AttributeError: 'module' object has no attribute 'dynamic_rnn_decoder'

It seems that tensorflow.contrib.seq2seq exists but does not have a dynamic_rnn_decoder function in version 12.1.0? Can you confirm that this is still working on your version and that you are in fact using tensorflow version 12.1.0.

Thanks!
Maddie

@wangliangguo
Copy link

tf.nn.rnn_cell.LSTMCell

@fd3kyt
Copy link

fd3kyt commented Feb 19, 2017

It seems that tf 0.12.1 doesn't have dynamic_rnn_decoder or simple_decoder_fn_train, I made it work on tf 1.0.0.

In layers.py:
replace

LSTMCell = rnn.LSTMCell
MultiRNNCell = rnn.MultiRNNCell
dynamic_rnn_decoder = seq2seq.dynamic_rnn_decoder
simple_decoder_fn_train = seq2seq.simple_decoder_fn_train

to

LSTMCell = tf.contrib.rnn.LSTMCell
MultiRNNCell = tf.contrib.rnn.MultiRNNCell
dynamic_rnn_decoder = tf.contrib.seq2seq.dynamic_rnn_decoder
simple_decoder_fn_train = tf.contrib.seq2seq.simple_decoder_fn_train

In model.py: change all tf.concat_v2 to tf.concat.

After that, it will still complain that tf.contrib.layers doesn't contain utils. I modified site-packages/tensorflow/contrib/layers/__init__.py, adding 'utils' into _allowed_symbols, and it worked. Perhap there is a better way to do this.

@tuan3w
Copy link

tuan3w commented Feb 19, 2017

I changed file model.py as link, and it worked with tensorflow v1.0 without any modification in tensorflow library.

@unnir
Copy link

unnir commented Sep 28, 2017

why did you close this issue? I still have the same problem

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