tf.shape和tf.less

tf.shape返回张量的形状

tf.less返回两个张量各元素比较(x

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]]

你可能感兴趣的:(TensorFlow)