tf.rank 返回tensor的维度

介绍

返回tensor的维度

语法

tf.rank(
    input,
    name=None
)
参数
  • input:tensor
返回值

返回 tensor 的维度,int32 型的tensor

例子

t = tf.constant([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]])
tf.rank(t).numpy()

执行结果:

3

原文出处:/show_1EF5bVVRcWII.html