最佳答案
使用tf.where
。例如,
x = np.random.rand(20,3)
sess = tf.Session()
print x[tf.where(tf.greater(x[:,2], 0.5)).eval(session=sess)]
或者稍微干净一点,
tf.boolean_mask(x,tf.greater(x[:,2], 0.5)).eval(session=sess)
关于python - 如何选择张量中的一组项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47490476/