Skip to content

Commit 1f0fa67

Browse files
committed
add some activation api examples.
1 parent dd6fd4c commit 1f0fa67

File tree

1 file changed

+44
-2
lines changed
  • python/paddle/fluid/layers

1 file changed

+44
-2
lines changed

python/paddle/fluid/layers/nn.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6833,6 +6833,13 @@ def elu(x, alpha=1.0, name=None):
68336833
68346834
Returns:
68356835
output(${out_type}): ${out_comment}
6836+
6837+
Examples:
6838+
6839+
.. code-block:: python
6840+
6841+
x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32")
6842+
y = fluid.layers.elu(x, alpha=0.2)
68366843
"""
68376844
helper = LayerHelper('elu', **locals())
68386845
out = helper.create_variable_for_type_inference(dtype=x.dtype)
@@ -6856,6 +6863,13 @@ def relu6(x, threshold=6.0, name=None):
68566863
68576864
Returns:
68586865
output(${out_type}): ${out_comment}
6866+
6867+
Examples:
6868+
6869+
.. code-block:: python
6870+
6871+
x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32")
6872+
y = fluid.layers.relu6(x, threshold=6.0)
68596873
"""
68606874
helper = LayerHelper('relu6', **locals())
68616875
out = helper.create_variable_for_type_inference(dtype=x.dtype)
@@ -6879,6 +6893,13 @@ def pow(x, factor=1.0, name=None):
68796893
68806894
Returns:
68816895
output(${out_type}): ${out_comment}
6896+
6897+
Examples:
6898+
6899+
.. code-block:: python
6900+
6901+
x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32")
6902+
y = fluid.layers.pow(x, factor=2.0)
68826903
"""
68836904
helper = LayerHelper('pow', **locals())
68846905
out = helper.create_variable_for_type_inference(dtype=x.dtype)
@@ -6903,6 +6924,13 @@ def stanh(x, scale_a=2.0 / 3.0, scale_b=1.7159, name=None):
69036924
69046925
Returns:
69056926
output(${out_type}): ${out_comment}
6927+
6928+
Examples:
6929+
6930+
.. code-block:: python
6931+
6932+
x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32")
6933+
y = fluid.layers.stanh(x, scale_a=0.6667, scale_b=1.7159)
69066934
"""
69076935
helper = LayerHelper('stanh', **locals())
69086936
out = helper.create_variable_for_type_inference(dtype=x.dtype)
@@ -6928,6 +6956,13 @@ def hard_sigmoid(x, slope=0.2, offset=0.5, name=None):
69286956
69296957
Returns:
69306958
output(${out_type}): ${out_comment}
6959+
6960+
Examples:
6961+
6962+
.. code-block:: python
6963+
6964+
x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32")
6965+
y = fluid.layers.hard_sigmoid(x, slope=0.3, offset=0.8)
69316966
"""
69326967
helper = LayerHelper('hard_sigmoid', **locals())
69336968
out = helper.create_variable_for_type_inference(dtype=x.dtype)
@@ -6952,6 +6987,13 @@ def swish(x, beta=1.0, name=None):
69526987
69536988
Returns:
69546989
output(${out_type}): ${out_comment}
6990+
6991+
Examples:
6992+
6993+
.. code-block:: python
6994+
6995+
x = fluid.layers.data(name="x", shape=[3,10,32,32], dtype="float32")
6996+
y = fluid.layers.swish(x, beta=1.2)
69556997
"""
69566998
helper = LayerHelper('swish', **locals())
69576999
out = helper.create_variable_for_type_inference(dtype=x.dtype)
@@ -6988,8 +7030,8 @@ def prelu(x, mode, param_attr=None, name=None):
69887030
.. code-block:: python
69897031
69907032
x = fluid.layers.data(name="x", shape=[10,10], dtype="float32")
6991-
mode = 'channel'
6992-
output = fluid.layers.prelu(x,mode)
7033+
mode = 'channel'
7034+
output = fluid.layers.prelu(x,mode)
69937035
"""
69947036
helper = LayerHelper('prelu', **locals())
69957037
if mode not in ['all', 'channel', 'element']:

0 commit comments

Comments
 (0)