tf.where()用法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Eric_LH/article/details/82757689

找出tensor里所有True值的index

import tensorflow as tf

a = tf.constant([False,False,True,False,True],dtype=tf.bool)
b = tf.where(tf.equal(a,True))
sess = tf.Session()
print(sess.run(b))

print:
[[2]
[4]]

猜你喜欢

转载自blog.csdn.net/Eric_LH/article/details/82757689