As stated in the title, is there a TensorFlow equivalent of the numpy.all() function to check if all the values in a bool tensor are True
? What is the best way to implement such a check?
Use tf.reduce_all, as follows:
import tensorflow as tf
a=tf.constant([True,False,True,True],dtype=tf.bool)
res=tf.reduce_all(a)
sess=tf.InteractiveSession()
res.eval()
This returns False
.
On the other hand, this returns True
:
import tensorflow as tf
a=tf.constant([True,True,True,True],dtype=tf.bool)
res=tf.reduce_all(a)
sess=tf.InteractiveSession()
res.eval()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With