TensorFlow张量变换函数:tf.shape

2018-01-22 10:46 更新

tf.shape 函数

shape(
    input,
    name=None,
    out_type=tf.int32
)

定义在:tensorflow/python/ops/array_ops.py.

参见指南:张量变换>形状的确定与改变

返回某个张量的形状.

此操作返回表示input形状的一维整数张量.

例如:

t = tf.constant([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]])
tf.shape(t)  # [2, 2, 3]

函数参数

  • input:表示一个Tensor或SparseTensor.
  • name:操作的名称(可选).
  • out_type:(可选)操作的指定输出类型((int32或int64));默认为tf.int32.

函数返回值

tf.shape 函数会返回out_type类型的Tensor.

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号