函数:tf.less
less( x, y, name=None )
以元素方式返回(x <y)的真值.
注意:Less支持广播.
参数:
- x:张量.必须是下列类型之一:float32,float64,int32,int64,uint8,int16,int8,uint16,half.
- y:张量.必须与 x 具有相同的类型.
- name:操作的名称(可选).
返回值:
该函数返回 bool 类型的张量.
举例:
import tensorflow as tf
A=[[1,2,3]]
t = tf.shape(A)
i=[3,2]
r = tf.less(i, t)
with tf.Session() as sess:
print(sess.run(t))
print(sess.run(r))
结果:
[1 3]
[False True]
import tensorflow as tf
A=[[1,2,3],
[4,5,6]]
t = tf.shape(A)
i=[[1,2,3],
[1,2,3]]
r = tf.less(i, A)
with tf.Session() as sess:
print(sess.run(t))
print(sess.run(r))
结果:
[2 3]
[[False False False]
[ True True True]]
参考文献:https://www.w3cschool.cn/tensorflow_python/tensorflow_python-fw182f4x.html