How to make an if statement using a boolean Tensor
<p>How do I make an if statement using a boolean tensor?  To be more precise, I'm trying to compare a tensor of size 1 to a constant, checking to see if the value in the tensor is less than the constant.  I figured out I have to make the constant its own size 1 tensor and use <a href="https://www.tensorflow.org/versions/master/api_docs/python/control_flow_ops.html#less" rel="noreferrer">this</a> method to check if the first tensor is less than the second tensor, but I'm not sure how to make the resulting boolean tensor fit correctly into an if statement.  Just putting it in as the query for the if statement makes if statement always return true.</p>

<p>EDIT:  This is more or less what the code looked like.  However, I'm getting the error <code>'bool' object has no attribute 'name'</code> regardless of whether it has parameters or not, which makes me think the problem is instead that it's not returning a TensorFlow object.</p>

<pre><code>pred = tf.placeholder(tf.bool)

def if_true(x, y, z):
  #act on x, y, and z
  return True

def if_false():
  return False

# Will be `tf.cond()` in the next release.
from tensorflow.python.ops import control_flow_ops
from functools import partial
x = ...
y = ...
z = ...

result = control_flow_ops.cond(pred, partial(if_true, x, y, z), if_false)
</code></pre>