Skip to content

Commit b651306

Browse files
authored
Merge pull request #14549 from wzzju/add-code-exp
add some activation api examples.
2 parents 1538059 + f6f31c3 commit b651306

File tree

1 file changed

+42
-0
lines changed
  • python/paddle/fluid/layers

1 file changed

+42
-0
lines changed

python/paddle/fluid/layers/nn.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6837,6 +6837,13 @@ def elu(x, alpha=1.0, name=None):
68376837
68386838
Returns:
68396839
output(${out_type}): ${out_comment}
6840+
6841+
Examples:
6842+
6843+
.. code-block:: python
6844+
6845+
x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32")
6846+
y = fluid.layers.elu(x, alpha=0.2)
68406847
"""
68416848
helper = LayerHelper('elu', **locals())
68426849
out = helper.create_variable_for_type_inference(dtype=x.dtype)
@@ -6860,6 +6867,13 @@ def relu6(x, threshold=6.0, name=None):
68606867
68616868
Returns:
68626869
output(${out_type}): ${out_comment}
6870+
6871+
Examples:
6872+
6873+
.. code-block:: python
6874+
6875+
x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32")
6876+
y = fluid.layers.relu6(x, threshold=6.0)
68636877
"""
68646878
helper = LayerHelper('relu6', **locals())
68656879
out = helper.create_variable_for_type_inference(dtype=x.dtype)
@@ -6883,6 +6897,13 @@ def pow(x, factor=1.0, name=None):
68836897
68846898
Returns:
68856899
output(${out_type}): ${out_comment}
6900+
6901+
Examples:
6902+
6903+
.. code-block:: python
6904+
6905+
x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32")
6906+
y = fluid.layers.pow(x, factor=2.0)
68866907
"""
68876908
helper = LayerHelper('pow', **locals())
68886909
out = helper.create_variable_for_type_inference(dtype=x.dtype)
@@ -6907,6 +6928,13 @@ def stanh(x, scale_a=2.0 / 3.0, scale_b=1.7159, name=None):
69076928
69086929
Returns:
69096930
output(${out_type}): ${out_comment}
6931+
6932+
Examples:
6933+
6934+
.. code-block:: python
6935+
6936+
x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32")
6937+
y = fluid.layers.stanh(x, scale_a=0.67, scale_b=1.72)
69106938
"""
69116939
helper = LayerHelper('stanh', **locals())
69126940
out = helper.create_variable_for_type_inference(dtype=x.dtype)
@@ -6932,6 +6960,13 @@ def hard_sigmoid(x, slope=0.2, offset=0.5, name=None):
69326960
69336961
Returns:
69346962
output(${out_type}): ${out_comment}
6963+
6964+
Examples:
6965+
6966+
.. code-block:: python
6967+
6968+
x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32")
6969+
y = fluid.layers.hard_sigmoid(x, slope=0.3, offset=0.8)
69356970
"""
69366971
helper = LayerHelper('hard_sigmoid', **locals())
69376972
out = helper.create_variable_for_type_inference(dtype=x.dtype)
@@ -6956,6 +6991,13 @@ def swish(x, beta=1.0, name=None):
69566991
69576992
Returns:
69586993
output(${out_type}): ${out_comment}
6994+
6995+
Examples:
6996+
6997+
.. code-block:: python
6998+
6999+
x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32")
7000+
y = fluid.layers.swish(x, beta=2.0)
69597001
"""
69607002
helper = LayerHelper('swish', **locals())
69617003
out = helper.create_variable_for_type_inference(dtype=x.dtype)

0 commit comments

Comments
 (0)