Skip to content

Fix English doc of the activation OPs, such as exp, rsqrt, abs....... #25258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 30, 2020
13 changes: 11 additions & 2 deletions python/paddle/fluid/layers/layer_function_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,16 @@ def func(x, name=None):

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())
Expand All @@ -297,7 +299,14 @@ def func(x, name=None):
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


Expand Down