Skip to content

Commit

Permalink
fix typos, test=develop
Browse files Browse the repository at this point in the history
  • Loading branch information
qili93 committed Aug 20, 2020
1 parent 4598d4c commit ffe3a06
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
22 changes: 16 additions & 6 deletions python/paddle/nn/functional/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def prelu(x, weight, name=None):
.. math::
prelu(x) = max(0, x) + \weight * min(0, x)
prelu(x) = max(0, x) + weight * min(0, x)
Parameters:
x (Tensor): The input Tensor with data type float32, float64.
Expand All @@ -420,11 +420,21 @@ def prelu(x, weight, name=None):
paddle.disable_static()
x = paddle.to_tensor(np.array([[-1,6],[1,15.6]]))
weight = paddle.to_tensor(np.array([0.2]))
out = F.prelu(x, weight)
# [[-0.12642411 6. ]
# [ 1. 15.6 ]]
data = np.array([[[[-2.0, 3.0, -4.0, 5.0],
[ 3.0, -4.0, 5.0, -6.0],
[-7.0, -8.0, 8.0, 9.0]],
[[ 1.0, -2.0, -3.0, 4.0],
[-5.0, 6.0, 7.0, -8.0],
[ 6.0, 7.0, 8.0, 9.0]]]], 'float32')
x = paddle.to_tensor(data)
w = paddle.to_tensor(np.array([0.25]).astype('float32'))
out = F.prelu(x, w)
# [[[[-0.5 , 3. , -1. , 5. ],
# [ 3. , -1. , 5. , -1.5 ],
# [-1.75, -2. , 8. , 9. ]],
# [[ 1. , -0.5 , -0.75, 4. ],
# [-1.25, 6. , 7. , -2. ],
# [ 6. , 7. , 8. , 9. ]]]]
"""
check_variable_and_dtype(x, 'x', ['float16', 'float32', 'float64'], 'prelu')
check_variable_and_dtype(weight, 'weight',
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/nn/layer/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class PReLU(layers.Layer):
.. math:
PReLU(x) = max(0, x) + \weight * min(0, x)
PReLU(x) = max(0, x) + weight * min(0, x)
Parameters:
num_parameters (int, optional): Number of `weight` to learn. The supported values are:
Expand Down

0 comments on commit ffe3a06

Please sign in to comment.