Matrix tensorflow:如何根据条件选择矩阵行

Matrix tensorflow:如何根据条件选择矩阵行,matrix,tensorflow,where-clause,Matrix,Tensorflow,Where Clause,我找到了类似的解决方案。然而,该解决方案基于一个条件在两个矩阵之间进行二进制选择。我需要做的是只选择满足条件的行。我怎样才能做到这一点 我会简单介绍这项质询。例如: tf.InteractiveSession() yt = tf.constant([10,1,10]) a = tf.constant([1,2,3]) b = tf.constant([3,4,5]) tf.where(tf.less(yt,[5]), a, b).eval() 如果关联的yt值小于5,则结果将从a中选择一个值,

我找到了类似的解决方案。然而,该解决方案基于一个条件在两个矩阵之间进行二进制选择。我需要做的是只选择满足条件的行。我怎样才能做到这一点

我会简单介绍这项质询。例如:

tf.InteractiveSession()
yt = tf.constant([10,1,10])
a = tf.constant([1,2,3])
b = tf.constant([3,4,5])
tf.where(tf.less(yt,[5]), a, b).eval()
如果关联的
yt
值小于5,则结果将从
a
中选择一个值,否则从
b
中选择一个值。我需要的是从
a
中选择一个值,如果
yt您可以执行以下操作:

a[tf.squeeze(tf.where(tf.less(yt,[5]), None, None))
你可以做:

a[tf.squeeze(tf.where(tf.less(yt,[5]), None, None))