未验证 提交 cacbfe4e 编写于 作者: Z zhouwei25 提交者: GitHub

Synchronize Chinese and English DOC of API:layers.sum (#1507)

Fix fluid.layers.data of example code, Synchronize Chinese and English DOC of API:layers.sum.
上级 21311e9f
......@@ -48,13 +48,28 @@ sum
**代码示例:**
.. code-block:: python
import paddle.fluid as fluid
import paddle.fluid.layers as layers
input0 = layers.data(name="input0", shape=[13, 11], dtype='float32')
input1 = layers.data(name="input1", shape=[13, 11], dtype='float32')
out = layers.sum([input0,input1])
import paddle.fluid as fluid
input0 = fluid.layers.fill_constant(shape=[2, 3], dtype='int64', value=5)
input1 = fluid.layers.fill_constant(shape=[2, 3], dtype='int64', value=3)
sum = fluid.layers.sum([input0, input1])
#用户可以通过executor打印出求和的结果
out = fluid.layers.Print(sum, message="the sum of input0 and input1: ")
exe = fluid.Executor(fluid.CPUPlace())
exe.run(fluid.default_main_program())
#打印出的数据为:
1570701754 the sum of input0 and input1: The place is:CPUPlace
Tensor[sum_0.tmp_0]
shape: [2,3,]
dtype: l
data: 8,8,8,8,8,8,
#输出了shape为[2,3]的Tensor,与输入的shape一致
#dtype为对应C++数据类型,在不同环境下可能显示值不同,但本质相同
#例如:如果Tensor中数据类型是int64,则对应的C++数据类型为int64_t,所以dtype值为typeid(int64_t).name(),
# 其在MacOS下为'x',linux下为'l',Windows下为'__int64',都表示64位整型变量
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册