carpedm20 / lstm-char-cnn-tensorflow

in progress
MIT License
761 stars 243 forks source link

`tf.Tensor` as Python boolean error #8

Closed aigujin closed 8 years ago

aigujin commented 8 years ago

Hi, While running python main.py --dataset ptb, I got an error :

data = data[: batch_size * seq_length * math.floor(length / (batch_size * seq_length))]
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 "/usr/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 30, in run sys.exit(main(sys.argv))
File "main.py", line 60, in main model.run(FLAGS.epoch, FLAGS.learning_rate, FLAGS.decay)
File "/Users/artur-imac/nn-models/lstm-char-cnn-tensorflow/models/LSTMTDNN.py", line 269, in run
    if grad:
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 475, in __nonzero__
    raise TypeError("Using a `tf.Tensor` as a Python `bool` is not allowed. "
TypeError: Using a `tf.Tensor` as a Python `bool` is not allowed. Use `if t is not None:` instead of `if t:` to test if a tensor is defined, and use the logical TensorFlow ops to test the value of a tensor.

I am using TensorFlow 0.8 with Python2.

carpedm20 commented 8 years ago

@aigujin Thanks. This was because of the recent updates.