From 50db851242c9dc2c71c96ccdcda38a040a3059b7 Mon Sep 17 00:00:00 2001 From: hong19860320 <9973393+hong19860320@users.noreply.github.com> Date: Wed, 25 Sep 2019 19:02:37 +0800 Subject: [PATCH] update cn doc for assign op (#1378) * update cn doc for assign op * refine the description of assign op --- doc/fluid/api_cn/layers_cn/assign_cn.rst | 29 +++++++++--------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/doc/fluid/api_cn/layers_cn/assign_cn.rst b/doc/fluid/api_cn/layers_cn/assign_cn.rst index 24a974e4d..f7f18c7cf 100644 --- a/doc/fluid/api_cn/layers_cn/assign_cn.rst +++ b/doc/fluid/api_cn/layers_cn/assign_cn.rst @@ -5,31 +5,24 @@ assign .. py:function:: paddle.fluid.layers.assign(input,output=None) -该函数将输入变量复制到输出变量 +该OP将输入Tensor或numpy数组拷贝至输出Tensor。 参数: - - **input** (Variable|numpy.ndarray)-源变量 - - **output** (Variable|None)-目标变量 + - **input** (Variable|np.ndarray) - 输入Tensor或numpy数组,支持数据类型为float32, float64, int32和int64。 + - **output** (Variable,可选) - 输出Tensor。如果为None,则创建一个新的Tensor作为输出Tensor,默认值为None。 -返回:作为输出的目标变量 +返回:输出Tensor,形状、数据类型、数据值和 ``input`` 一致。 -返回类型:变量(Variable) +返回类型:Variable **代码示例**: .. code-block:: python import paddle.fluid as fluid - data = fluid.layers.data(name="data", shape=[3, 32, 32], dtype="float32") - out = fluid.layers.create_tensor(dtype='float32') - hidden = fluid.layers.fc(input=data, size=10) - fluid.layers.assign(hidden, out) - - - - - - - - - + import numpy as np + data = fluid.layers.fill_constant(shape=[3, 2], value=2.5, dtype='float64') # [[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]] + result1 = fluid.layers.create_tensor(dtype='float64') + fluid.layers.assign(data, result1) # result1 = [[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]] + result2 = fluid.layers.assign(data) # result2 = [[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]] + result3 = fluid.layers.assign(np.array([[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]], dtype='float32')) # result3 = [[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]] -- GitLab