input.get_shape()
首先imput是一个张量,如果不是一个张量使用get_shape()会报错
返回的值l类型类似于元组的tensorshape
示例:
>>> input = tf.constant([[0,1,2],[3,4,5]])
>>> print(input.get_shape())
(2, 3)
>>> print(type(input.get_shape()))
<class 'tensorflow.python.framework.tensor_shape.TensorShape'>
>>> print(input.shape)
(2, 3)
>>> print(type(input.shape))
<class 'tensorflow.python.framework.tensor_shape.TensorShape'>
>>> print(tf.shape(input))
tf.Tensor([2 3], shape=(2,), dtype=int32)
>>> print(type(tf.shape(input)))
<class 'tensorflow.python.framework.ops.EagerTensor'>
>>> print(input.get_shape().as_list()) #将元组类型转化成列表
[2, 3]