tf.math.equal() 函数讲解
参数:tf.math.equal(a,b),其中a,b可以是tensor或者具体的数字。
作用:如果二者都是tensor(shape要一致)或数字,相同位置进行比较,返回TRUE or FALSE;
如果二者有一个为数字,则tensor的每个位置与该数字比较,返回TRUE or FALSE。
代码示例(jupyter lab):
a=[[1,2,0,0,1]]
s=tf.math.equal(a,0)
s
输出为
<tf.Tensor: shape=(1, 5), dtype=bool, numpy=array([[False, False, True, True, False]])>