如何获得Tensorflow形状

时间:2019-03-06 21:42:57

标签: tensorflow shapes

我在TensorFlow中具有以下常量:

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

现在我想知道它的形状。我尝试运行:

tf.shape(t)

我得到:     <tf.Tensor 'Shape:0' shape=(3,) dtype=int32>

我认为我应该看到类似[2,2,3]的内容。如何读取预期的形状值?

谢谢

1 个答案:

答案 0 :(得分:1)

您可能正在寻找返回TensorShape的tf.get_shape()