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

Using a tf.Tensor as a Python bool is not allowed. #3167

Closed
fobus42 opened this issue Jul 3, 2016 · 3 comments
Closed

Using a tf.Tensor as a Python bool is not allowed. #3167

fobus42 opened this issue Jul 3, 2016 · 3 comments

Comments

@fobus42
Copy link

fobus42 commented Jul 3, 2016

Environment info

Operating System: Linux Mint 17.3 Rosa
$uname -a

Linux Pabeda 3.19.0-32-generic #37~14.04.1-Ubuntu SMP Thu Oct 22 09:41:40 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

$python -c "import tensorflow; print(tensorflow.version)"
0.9.0

Steps to reproduce

$ git clone https://github.com/ilblackdragon/tf_examples.git
$ python titanic.py

What have you tried?

  1. I'm trying to run the tutorial on : https://medium.com/@ilblackdragon/tensorflow-tutorial-part-1-c559c63c0cb1#.1a7hit535

Errors

/usr/local/lib/python2.7/dist-packages/skflow/io/data_feeder.py:217: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
out.itemset((i, self.y[sample]), 1.0)
Traceback (most recent call last):
File "titanic.py", line 30, in
tflr.fit(X_train, y_train)
File "/usr/local/lib/python2.7/dist-packages/skflow/estimators/base.py", line 227, in fit
feed_params_fn=self._data_feeder.get_feed_params)
File "/usr/local/lib/python2.7/dist-packages/skflow/trainer.py", line 146, in train
if summaries:
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 528, 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.

@thinxer
Copy link
Contributor

thinxer commented Jul 6, 2016

This is not a TensorFlow issue. You should report to https://github.com/ilblackdragon/tf_examples not here.

Anyway, to fix it, just follow the instructions: replace if t with if t is not None.

@fobus42
Copy link
Author

fobus42 commented Jul 6, 2016

@ilblackdragon, what do you think about @thinxer's reponse?

@aselle
Copy link
Contributor

aselle commented Jul 7, 2016

Closing for now as now as this is intended behavior. Using implicit bool conversions is error prone which is why it is disallowed. Thanks!

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

3 participants