Skip to content

Commit 48be9dc

Browse files
authored
Merge pull request #14489 from tensor-tang/api/example
add api example of brelu, leaky_relu and soft_relu
2 parents 9eefd2c + e3645c2 commit 48be9dc

File tree

1 file changed

+24
-3
lines changed
  • python/paddle/fluid/layers

1 file changed

+24
-3
lines changed

python/paddle/fluid/layers/nn.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6949,8 +6949,15 @@ def brelu(x, t_min=0.0, t_max=24.0, name=None):
69496949
t_max(${t_max_type}|24.0): ${t_max_comment}
69506950
name(str|None): A name for this layer(optional). If set None, the layer
69516951
will be named automatically.
6952-
Returns:
6952+
Returns:
69536953
output(${out_type}): ${out_comment}
6954+
6955+
Examples:
6956+
6957+
.. code-block:: python
6958+
6959+
x = fluid.layers.data(name="x", shape=[2,3,16,16], dtype="float32")
6960+
y = fluid.layers.brelu(x, t_min=1.0, t_max=20.0)
69546961
"""
69556962
helper = LayerHelper('brelu', **locals())
69566963
out = helper.create_variable_for_type_inference(dtype=x.dtype)
@@ -6972,8 +6979,15 @@ def leaky_relu(x, alpha=0.02, name=None):
69726979
alpha(${alpha_type}|0.02): ${alpha_comment}
69736980
name(str|None): A name for this layer(optional). If set None, the layer
69746981
will be named automatically.
6975-
Returns:
6982+
Returns:
69766983
output(${out_type}): ${out_comment}
6984+
6985+
Examples:
6986+
6987+
.. code-block:: python
6988+
6989+
x = fluid.layers.data(name="x", shape=[2,3,16,16], dtype="float32")
6990+
y = fluid.layers.leaky_relu(x, alpha=0.01)
69776991
"""
69786992
helper = LayerHelper('leaky_relu', **locals())
69796993
out = helper.create_variable_for_type_inference(dtype=x.dtype)
@@ -6994,8 +7008,15 @@ def soft_relu(x, threshold=40.0, name=None):
69947008
threshold(${threshold_type}|40.0): ${threshold_comment}
69957009
name(str|None): A name for this layer(optional). If set None, the layer
69967010
will be named automatically.
6997-
Returns:
7011+
Returns:
69987012
output(${out_type}): ${out_comment}
7013+
7014+
Examples:
7015+
7016+
.. code-block:: python
7017+
7018+
x = fluid.layers.data(name="x", shape=[2,3,16,16], dtype="float32")
7019+
y = fluid.layers.soft_relu(x, threshold=20.0)
69997020
"""
70007021
helper = LayerHelper('soft_relu', **locals())
70017022
out = helper.create_variable_for_type_inference(dtype=x.dtype)

0 commit comments

Comments
 (0)