提交 04293dc3 编写于 作者: L lijianshe02

fix Print_op api_cn docs test=develop

上级 b58e4c66
......@@ -14,13 +14,13 @@ Print
参数:
- **input** (Variable)-将要打印的Tensor
- **summarize** (int)-打印Tensor中的元素数目,如果值为-1则打印所有元素
- **message** (str)-字符串类型消息,作为前缀打印
- **first_n** (int)-只记录first_n次数
- **print_tensor_name** (bool)-指明是否打印Tensor名称,默认为True
- **print_tensor_type** (bool)-指明是否打印Tensor类型,默认为True
- **print_tensor_shape** (bool)-指明是否打印Tensor维度信息,默认为True
- **print_tensor_lod** (bool)-指明是否打印Tensor的lod信息,默认为True
- **print_phase** (str)-指明打印的阶段,包括 ``forward`` , ``backward`` 和 ``both`` ,默认为 ``both`` 。若设置为 ``backward`` 或者 ``both`` ,则打印输入Tensor的梯度
- **message** (str)-打印Tensor信息前自定义的字符串类型消息,作为前缀打印
- **first_n** (int)-打印Tensor的次数
- **print_tensor_name** (bool)-可选,指明是否打印Tensor名称,默认为True
- **print_tensor_type** (bool)-可选,指明是否打印Tensor类型,默认为True
- **print_tensor_shape** (bool)-可选,指明是否打印Tensor维度信息,默认为True
- **print_tensor_lod** (bool)-可选,指明是否打印Tensor的lod信息,默认为True
- **print_phase** (str)-可选,指明打印的阶段,包括 ``forward`` , ``backward`` 和 ``both`` 。默认为 ``both`` 。设置为 ``forward`` 时,只打印Tensor的前向信息;设置为 ``backward`` 时,只打印Tensor的梯度信息;设置为 ``both`` 时,则同时打印Tensor的前向信息以及梯度信息
返回:输出Tensor
......@@ -34,28 +34,32 @@ Print
.. code-block:: python
import paddle.fluid as fluid
input = fluid.layers.fill_constant(shape=[10,2], value=3, dtype='int64')
input = fluid.layers.Print(input, message="The content of input layer:")
main_program = fluid.default_main_program()
exe = fluid.Executor(fluid.CPUPlace())
exe.run(main_program)
import paddle
import numpy as np
x = fluid.layers.data(name='x', shape=[1], dtype='float32', lod_level=1)
x = fluid.layers.Print(x, message="The content of input layer:")
y = fluid.layers.data(name='y', shape=[1], dtype='float32', lod_level=2)
out = fluid.layers.sequence_expand(x=x, y=y, ref_level=0)
place = fluid.CPUPlace()
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
x_d = fluid.create_lod_tensor(np.array([[1.1], [2.2],[3.3],[4.4]]).astype('float32'), [[1,3]], place)
y_d = fluid.create_lod_tensor(np.array([[1.1],[1.1],[1.1],[1.1],[1.1],[1.1]]).astype('float32'), [[1,3], [1,2,1,2]], place)
results = exe.run(fluid.default_main_program(),
feed={'x':x_d, 'y': y_d },
fetch_list=[out],return_numpy=False)
**运行输出**:
.. code-block:: bash
1564546375 输出层内容: place:CPUPlace
Tensor[fill_constant_0.tmp_0]
shape: [10,2,]
dtype: x
data: 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
# 不同的环境中运行时信息的类型可能不相同.
# 比如:
# 如果Tensor y dtype='int64', 相应的 c++ 类型为 int64_t.
# 在 MacOS 和 gcc4.8.2的环境中输出的dtype为 "x" ("x" is typeid(int64_t).name()) 。
The content of input layer: The place is:CPUPlace
Tensor[x]
shape: [4,1,]
dtype: f
LoD: [[ 0,1,4, ]]
data: 1.1,2.2,3.3,4.4,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册