如何打印张量的形状值?
How to print the value of shape of the tensor?
我用的是函数
print tf.shape(image)
输出喜欢
Tensor("Shape:0", shape=(3,), dtype=int32, device=/device:CPU:0)
我想知道形状内部的值是多少(比如尺寸)。我怎样才能访问它进行打印?
tf.shape
returns 包含参数形状的张量。当其中一个维度是 动态 时,这很有用,即 None
是静态的。
您可以使用image.shape
(或image.get_shape()
)来获取静态形状,或者也可以在会话中计算tf.shape(image)
。
另见 this answer。
我用的是函数
print tf.shape(image)
输出喜欢
Tensor("Shape:0", shape=(3,), dtype=int32, device=/device:CPU:0)
我想知道形状内部的值是多少(比如尺寸)。我怎样才能访问它进行打印?
tf.shape
returns 包含参数形状的张量。当其中一个维度是 动态 时,这很有用,即 None
是静态的。
您可以使用image.shape
(或image.get_shape()
)来获取静态形状,或者也可以在会话中计算tf.shape(image)
。
另见 this answer。