未验证 提交 50db8512 编写于 作者: H hong19860320 提交者: GitHub

update cn doc for assign op (#1378)

* update cn doc for assign op

* refine the description of assign op
上级 d26fd644
...@@ -5,31 +5,24 @@ assign ...@@ -5,31 +5,24 @@ assign
.. py:function:: paddle.fluid.layers.assign(input,output=None) .. py:function:: paddle.fluid.layers.assign(input,output=None)
函数将输入变量复制到输出变量 OP将输入Tensor或numpy数组拷贝至输出Tensor。
参数: 参数:
- **input** (Variable|numpy.ndarray)-源变量 - **input** (Variable|np.ndarray) - 输入Tensor或numpy数组,支持数据类型为float32, float64, int32和int64。
- **output** (Variable|None)-目标变量 - **output** (Variable,可选) - 输出Tensor。如果为None,则创建一个新的Tensor作为输出Tensor,默认值为None。
返回:作为输出的目标变量 返回:输出Tensor,形状、数据类型、数据值和 ``input`` 一致。
返回类型:变量(Variable) 返回类型:Variable
**代码示例**: **代码示例**:
.. code-block:: python .. code-block:: python
import paddle.fluid as fluid import paddle.fluid as fluid
data = fluid.layers.data(name="data", shape=[3, 32, 32], dtype="float32") import numpy as np
out = fluid.layers.create_tensor(dtype='float32') 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]]
hidden = fluid.layers.fc(input=data, size=10) result1 = fluid.layers.create_tensor(dtype='float64')
fluid.layers.assign(hidden, out) 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]]
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册