如何获得 Tensorflow 形状

How get Tensorflow shape

我在 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] 的内容。如何读取预期的形状值?

谢谢

您可能正在寻找 tf.get_shape(),其中 returns TensorShape。