From 6bf7df475cc0828edf2719c85431d10ad7123096 Mon Sep 17 00:00:00 2001 From: WuHaobo <14162525+WuHaobo@users.noreply.github.com> Date: Tue, 30 Jun 2020 21:21:47 +0800 Subject: [PATCH] Fix English doc of the activation OPs, such as exp, rsqrt, abs....... (#25258) --- .../paddle/fluid/layers/layer_function_generator.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/python/paddle/fluid/layers/layer_function_generator.py b/python/paddle/fluid/layers/layer_function_generator.py index 1ee8ba12d83..a84276cc6a1 100755 --- a/python/paddle/fluid/layers/layer_function_generator.py +++ b/python/paddle/fluid/layers/layer_function_generator.py @@ -281,14 +281,16 @@ def generate_activation_fn(op_type): Return type Variable + Examples: .. code-block:: python + import paddle import paddle.fluid as fluid import numpy as np inputs = fluid.data(name="x", shape = [None, 4], dtype='float32') - output = fluid.layers.%s(inputs) + output = paddle.%s(inputs) exe = fluid.Executor(fluid.CPUPlace()) exe.run(fluid.default_startup_program()) @@ -297,7 +299,14 @@ Examples: img = np.array([[1.0, 2.0, 3.0, 4.0]]).astype(np.float32) res = exe.run(fluid.default_main_program(), feed={'x':img}, fetch_list=[output]) print(res) -""" % op_type + + # using dygraph + with paddle.imperative.guard(): + dygraph_input = paddle.imperative.to_variable(img) + dygraph_output = paddle.%s(dygraph_input) + print(dygraph_output.numpy()) +""" % (op_type, op_type) + return func -- GitLab