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. #8322

Closed
danlutan opened this issue Mar 12, 2017 · 3 comments
Closed

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

danlutan opened this issue Mar 12, 2017 · 3 comments

Comments

@danlutan
Copy link

I want to do : IF True: return a ; else : return b (in python) . But there is a error : Using a tf.Tensor as a Python bool is not allowed. How can I do this

@GR3C0
Copy link

GR3C0 commented Mar 12, 2017 via email

@danlutan
Copy link
Author

c=tf.placeholder(tf.bool) if c : loss=-tf.reduce_sum(lable * tf.log(lable2))

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 TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor.

@concretevitamin
Copy link
Contributor

This is intended. Please use tf.cond.

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