如何获得Tensorflow的形状

问题描述 投票:0回答:1

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

谢谢

tensorflow shapes
1个回答
1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.