函數: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