carpedm20 / lstm-char-cnn-tensorflow

in progress
MIT License
761 stars 243 forks source link

TypeError: 'module' object is not callable #1

Closed DavidNemeskey closed 8 years ago

DavidNemeskey commented 8 years ago

I tried to run the code (python main.py --dataset ptb), and it failed with this exception:

...
Creating vocab...
After first pass of data, max word length is: 21
Token count: train 929589, val 73760, test 82430
Loading vocab...
Word vocab size: 10001, Char vocab size: 51
Reshaping tensors...
data load done. Number of batches in train: 265, val: 21, test: 23
Word vocab size: 10001, Char vocab size: 51, Max word length (incl. padding): 21
Traceback (most recent call last):
  File "main.py", line 66, in <module>
    tf.app.run()
  File "/home/ndavid/venvs/embedding/local/lib/python2.7/site-packages/tensorflow/python/platform/default/_app.py", line 11, in run
    sys.exit(main(sys.argv))
  File "main.py", line 57, in main
    data_dir=FLAGS.data_dir)
  File "/mnt/store/ndavid/LM/Others/lstm-char-cnn-tensorflow/models/LSTMTDNN.py", line 86, in __init__
    self.prepare_model()
  File "/mnt/store/ndavid/LM/Others/lstm-char-cnn-tensorflow/models/LSTMTDNN.py", line 144, in prepare_model
    cnn_output = highway(cnn_output, cnn_output.get_shape()[1], self.highway_layers, 0)
  File "/mnt/store/ndavid/LM/Others/lstm-char-cnn-tensorflow/models/ops.py", line 28, in highway
    output = f(rnn_cell.linear(output, size, 0, scope='output_lin_%d' % idx))
TypeError: 'module' object is not callable

I am using tensorflow version 0.5 (I think that's the latest one, but I am not sure).

carpedm20 commented 8 years ago

The most recent Tensorflow is 0.6 and I think there is a problem in rnn_cell.linear. In Tensorflow 0.5, linear was in rnn.linear not rnn_cell.linear. You'd better update it or chagne the path.