hunkim / word-rnn-tensorflow

Multi-layer Recurrent Neural Networks (LSTM, RNN) for word-level language models in Python using TensorFlow.
MIT License
1.3k stars 493 forks source link

Cannot train: 'tuple' object has no attribute 'eval' #9

Closed wichtounet closed 8 years ago

wichtounet commented 8 years ago

Hi,

I tried this implementation of word-rnn and I have an issue with the train script:

Traceback (most recent call last): File "train.py", line 111, in main() File "train.py", line 48, in main train(args) File "train.py", line 93, in train state = model.initial_state.eval() AttributeError: 'tuple' object has no attribute 'eval'

I'm using the last version of tensorflow and Python 3.4.

I've already had this issue with one other tensorflow project so I guesss there must be something wrong with my installation.

Thanks

zichaow commented 8 years ago

I got exactly the same problem with Python 2.7. I think the problem comes from initial_tuple which is organized as a tuple. Previously it is not a tuple.

hunkim commented 8 years ago

Thanks! Do you know which version of TF did you use?

On Fri, Sep 2, 2016 at 7:35 AM, moonlightlane notifications@github.com wrote:

I got exactly the same problem with Python 2.7. I think the problem comes from initial_tuple which is organized as a tuple. Previously it is not a tuple.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hunkim/word-rnn-tensorflow/issues/9#issuecomment-244243937, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3DV4S8kxLDQcDSE4tSMp-8__KUfFC5ks5ql2FJgaJpZM4Jq9_O .

zichaow commented 8 years ago

I think it is 0.10. There are some posts on github about this issue but none of them work for me... model.initial_state looks like this: (LSTMStateTuple(c=<tf.Tensor 'zeros:0' shape=(50, 128) dtype=float32>, h=<tf.Tensor 'zeros_1:0' shape=(50, 128) dtype=float32>), LSTMStateTuple(c=<tf.Tensor 'zeros_2:0' shape=(50, 128) dtype=float32>, h=<tf.Tensor 'zeros_3:0' shape=(50, 128) dtype=float32>)) , and it seems that the state is a tuple of tuples. I don't yet have a good idea how to deal with it.

hunkim commented 8 years ago

Let me try with 0.10. Thanks!

On Fri, Sep 2, 2016 at 7:56 AM, moonlightlane notifications@github.com wrote:

I think it is 0.10. There are some posts on github about this issue but none of them work for me... model.initial_state looks like this: (LSTMStateTuple(c=<tf.Tensor 'zeros:0' shape=(50, 128) dtype=float32>, h=<tf.Tensor 'zeros_1:0' shape=(50, 128) dtype=float32>), LSTMStateTuple(c=<tf.Tensor 'zeros_2:0' shape=(50, 128) dtype=float32>, h=<tf.Tensor 'zeros_3:0' shape=(50, 128) dtype=float32>)) , and it seems that the state is a tuple of tuples. I don't yet have a good idea how to deal with it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hunkim/word-rnn-tensorflow/issues/9#issuecomment-244247167, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3DV5LOM5ZpOeXgAPXs3XffQRIOibKTks5ql2Y2gaJpZM4Jq9_O .

astr010 commented 8 years ago

I am using Ubuntu/Linux 64-bit CPU Only, Python 2.7 Tensorflow-0.11 and the work around in the issue below fixed this issue for me https://github.com/sherjilozair/char-rnn-tensorflow/issues/47

TL;DR in train.py try replacing the line state = model.initial_state.eval() with model.initial_state = tf.convert_to_tensor(model.initial_state) state = model.initial_state.eval()

hunkim commented 8 years ago

Can you write a pull request for us?

Sung

On Wed, Oct 5, 2016 at 11:14 AM, astr010 notifications@github.com wrote:

I am using Ubuntu/Linux 64-bit CPU Only, Python 2.7 Tensorflow-0.11 and the work around in the issue below fixed this issue for me sherjilozair/char-rnn-tensorflow#47 https://github.com/sherjilozair/char-rnn-tensorflow/issues/47

TL;DR in train.py try replacing the line state = model.initial_state.eval() with model.initial_state = tf.convert_to_tensor(model.initial_state) state = model.initial_state.eval()

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hunkim/word-rnn-tensorflow/issues/9#issuecomment-251571748, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3DV02yQDz4ftd3YTjC3ij3k8_w3a2yks5qwxX5gaJpZM4Jq9_O .

wichtounet commented 8 years ago

I made a PR but using sess.run(x) instead of convert_to_tensor and then eval. I tested it on two machines one with standard installation and one with CUDA installation (the one with the original issue).

hunkim commented 8 years ago

Please reopen if this issue reoccurs.