From 81c127d4ec0ec40f2b7a25aba477f44a0dee43f9 Mon Sep 17 00:00:00 2001 From: zhupengyang Date: Sat, 22 Aug 2020 16:36:39 +0800 Subject: [PATCH] refine leaky_relu docs (#26558) --- python/paddle/nn/functional/activation.py | 12 ++++++------ python/paddle/nn/layer/activation.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/python/paddle/nn/functional/activation.py b/python/paddle/nn/functional/activation.py index 5c6f8139ca9..a3abca8417d 100644 --- a/python/paddle/nn/functional/activation.py +++ b/python/paddle/nn/functional/activation.py @@ -419,7 +419,7 @@ def leaky_relu(x, negative_slope=0.01, name=None): paddle.disable_static() - x = paddle.to_tensor(np.array([-2, 0, 1])) + x = paddle.to_tensor(np.array([-2, 0, 1], 'float32')) out = F.leaky_relu(x) # [-0.02, 0., 1.] """ @@ -466,11 +466,11 @@ def prelu(x, weight, name=None): paddle.disable_static() 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') + [ 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) diff --git a/python/paddle/nn/layer/activation.py b/python/paddle/nn/layer/activation.py index ed5913565e9..dcf037a38d7 100644 --- a/python/paddle/nn/layer/activation.py +++ b/python/paddle/nn/layer/activation.py @@ -625,7 +625,7 @@ class LeakyReLU(layers.Layer): paddle.disable_static() m = paddle.nn.LeakyReLU() - x = paddle.to_tensor(np.array([-2, 0, 1])) + x = paddle.to_tensor(np.array([-2, 0, 1], 'float32')) out = m(x) # [-0.02, 0., 1.] """ -- GitLab