TensorFlow之tf.less()


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

     https://blog.csdn.net/stt12345678/article/details/83987675


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM