input.get_shape()的用法
生活随笔
收集整理的这篇文章主要介绍了
input.get_shape()的用法
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
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]
总结
以上是生活随笔为你收集整理的input.get_shape()的用法的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 目标检测 /yolo算法原理的详解
- 下一篇: tf.pad函数功能介绍