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

fix_copy_if_different
WuHaobo 5 years ago committed by GitHub
parent 001c0674ee
commit 6bf7df475c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -281,14 +281,16 @@ def generate_activation_fn(op_type):
Return type Return type
Variable Variable
Examples: Examples:
.. code-block:: python .. code-block:: python
import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
import numpy as np import numpy as np
inputs = fluid.data(name="x", shape = [None, 4], dtype='float32') 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 = fluid.Executor(fluid.CPUPlace())
exe.run(fluid.default_startup_program()) 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) 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]) res = exe.run(fluid.default_main_program(), feed={'x':img}, fetch_list=[output])
print(res) 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 return func

Loading…
Cancel
Save