From 3c470caa04a9ba48caa73f03ab8822ca0578e855 Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Tue, 26 May 2020 14:00:40 +0800 Subject: [PATCH] add selectedrows in shape doc (#2176) --- doc/fluid/api_cn/layers_cn/shape_cn.rst | 26 +++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/doc/fluid/api_cn/layers_cn/shape_cn.rst b/doc/fluid/api_cn/layers_cn/shape_cn.rst index 5f5c2e670..acc2cb03b 100644 --- a/doc/fluid/api_cn/layers_cn/shape_cn.rst +++ b/doc/fluid/api_cn/layers_cn/shape_cn.rst @@ -13,12 +13,30 @@ shape shape层。 -获得输入Tensor的shape。 +获得输入Tensor或SelectedRows的shape。 + +:: + + 示例1: + 输入是 N-D Tensor类型: + input = [ [1, 2, 3, 4], [5, 6, 7, 8] ] + + 输出shape: + input.shape = [2, 4] + + 示例2: + 输入是 SelectedRows类型: + input.rows = [0, 4, 19] + input.height = 20 + input.value = [ [1, 2], [3, 4], [5, 6] ] # inner tensor + 输出shape: + input.shape = [3, 2] 参数: - - **input** (Variable)- 输入的多维Tensor,数据类型为float32,float64,int32,int64。 + - **input** (Variable)- 输入的多维Tensor或SelectedRows,数据类型为float32,float64,int32,int64。如果输入是SelectedRows类型,则返回其内部持有Tensor的shape。 + -返回: 一个Tensor,表示输入Tensor的shape。 +返回: 一个Tensor,表示输入Tensor或SelectedRows的shape。 返回类型: Variable(Tensor)。 @@ -29,7 +47,7 @@ shape层。 import paddle.fluid as fluid import numpy as np - inputs = fluid.layers.data(name="x", shape=[3, 100, 100], dtype="float32") + inputs = fluid.data(name="x", shape=[3, 100, 100], dtype="float32") output = fluid.layers.shape(inputs) exe = fluid.Executor(fluid.CPUPlace()) -- GitLab