input.get_shape()的用法
生活随笔
收集整理的這篇文章主要介紹了
input.get_shape()的用法
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
input.get_shape()
首先imput是一個(gè)張量,如果不是一個(gè)張量使用get_shape()會(huì)報(bào)錯(cuò)
返回的值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()) #將元組類型轉(zhuǎn)化成列表 [2, 3]?
總結(jié)
以上是生活随笔為你收集整理的input.get_shape()的用法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 目标检测 /yolo算法原理的详解
- 下一篇: tf.pad函数功能介绍