TF2.0-tf.where()

 tf.where(condition, x=None, y=None, name=None)

A = tf.where([True, False], [11,12], [22, 33])
print(A)

结果:

tf.Tensor([11 33], shape=(2,), dtype=int32)

三目运算,相当于C语言中的 

  A=condition?x:y

当condition为真时结果取x,否则结果取y

猜你喜欢

转载自blog.csdn.net/menghaocheng/article/details/91970057
tf