DeepRNN / image_captioning

Tensorflow implementation of "Show, Attend and Tell: Neural Image Caption Generation with Visual Attention"
MIT License
787 stars 354 forks source link

AttributeError: 'module' object has no attribute 'rnn_cell' on model.py #38

Open rola93 opened 6 years ago

rola93 commented 6 years ago

Hello

I'm trying to run it with weigths provided, however I didn't found our environment's setting (python version? dependencies versions?) So I'm running it on python 2.7.

I got the following error:

(captioning) rola93@rola93-Latitude-E5520:~/no_version/image_captioning$ python main.py --phase=test     --model_file='./models/289999/289999.npy' --beam_size=3
2018-08-08 14:50:20.015861: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2018-08-08 14:50:20.015898: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2018-08-08 14:50:20.015922: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
Building the vocabulary...
Vocabulary built.
Number of words = 5000
Building the dataset...
Dataset built.
Building the CNN...
CNN built.
Building the RNN...
Traceback (most recent call last):
  File "main.py", line 69, in <module>
    tf.app.run()
  File "/home/rola93/.pyenv/versions/captioning_2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "main.py", line 63, in main
    model = CaptionGenerator(config)
  File "/home/rola93/no_version/image_captioning/base_model.py", line 27, in __init__
    self.build()
  File "/home/rola93/no_version/image_captioning/model.py", line 10, in build
    self.build_rnn()
  File "/home/rola93/no_version/image_captioning/model.py", line 228, in build_rnn
    lstm = tf.nn.rnn_cell.LSTMCell(
AttributeError: 'module' object has no attribute 'rnn_cell'

According to this tf.nn.rnn_cell.LSTMCell was moved to contrib, so instead of lstm = tf.nn.rnn_cell.LSTMCell it should be lstm = tf.contrib.rnn.LSTMCell

I tried it, and worked (actually it breaks anyway, but i'm sure it's another problem).

Does it make sense?

thank you!

mey5634 commented 5 years ago

try tensorflow==1.8.0