欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

input.get_shape()的用法

发布时间:2024/9/21 编程问答 38 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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()的用法的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。