Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
a7db9acc
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a7db9acc
编写于
8月 28, 2020
作者:
H
hong19860320
提交者:
GitHub
8月 28, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add the constraint for the scale of SELU/selu (#26686)
上级
5f524efe
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
4 deletion
+17
-4
python/paddle/fluid/tests/unittests/test_selu_op.py
python/paddle/fluid/tests/unittests/test_selu_op.py
+5
-0
python/paddle/nn/functional/activation.py
python/paddle/nn/functional/activation.py
+10
-2
python/paddle/nn/layer/activation.py
python/paddle/nn/layer/activation.py
+2
-2
未找到文件。
python/paddle/fluid/tests/unittests/test_selu_op.py
浏览文件 @
a7db9acc
...
...
@@ -130,6 +130,11 @@ class TestSeluAPI(unittest.TestCase):
# The input dtype must be float16, float32, float64.
x_int32
=
paddle
.
data
(
name
=
'x_int32'
,
shape
=
[
12
,
10
],
dtype
=
'int32'
)
self
.
assertRaises
(
TypeError
,
F
.
selu
,
x_int32
)
# The scale must be greater than 1.0
x_fp32
=
paddle
.
data
(
name
=
'x_fp32'
,
shape
=
[
12
,
10
],
dtype
=
'float32'
)
self
.
assertRaises
(
ValueError
,
F
.
selu
,
x_fp32
,
-
1.0
)
# The alpha must be no less than 0
self
.
assertRaises
(
ValueError
,
F
.
selu
,
x_fp32
,
1.6
,
-
1.0
)
# support the input dtype is float16
x_fp16
=
paddle
.
data
(
name
=
'x_fp16'
,
shape
=
[
12
,
10
],
dtype
=
'float16'
)
F
.
selu
(
x_fp16
)
...
...
python/paddle/nn/functional/activation.py
浏览文件 @
a7db9acc
...
...
@@ -652,8 +652,8 @@ def selu(x,
Parameters:
x (Tensor): The input Tensor with data type float32, float64.
scale (float, optional): The value of scale for selu. Default is 1.0507009873554804934193349852946
alpha (float, optional): The value of alpha for selu. Default is 1.6732632423543772848170429916717
scale (float, optional): The value of scale
(must be greater than 1.0)
for selu. Default is 1.0507009873554804934193349852946
alpha (float, optional): The value of alpha
(must be no less than zero)
for selu. Default is 1.6732632423543772848170429916717
name (str, optional): Name for the operation (optional, default is None).
For more information, please refer to :ref:`api_guide_Name`.
...
...
@@ -672,6 +672,14 @@ def selu(x,
x = paddle.to_tensor(np.array([[0.0, 1.0],[2.0, 3.0]]))
out = F.selu(x) # [[0, 1.050701],[2.101402, 3.152103]]
"""
if
scale
<=
1.0
:
raise
ValueError
(
"The scale must be greater than 1.0. Received: {}."
.
format
(
scale
))
if
alpha
<
0
:
raise
ValueError
(
"The alpha must be no less than zero. Received: {}."
.
format
(
alpha
))
if
in_dygraph_mode
():
return
core
.
ops
.
selu
(
x
,
'scale'
,
scale
,
'alpha'
,
alpha
)
...
...
python/paddle/nn/layer/activation.py
浏览文件 @
a7db9acc
...
...
@@ -559,8 +559,8 @@ class SELU(layers.Layer):
\\
end{cases}
Parameters:
scale (float, optional): The value of scale for SELU. Default is 1.0507009873554804934193349852946
alpha (float, optional): The value of alpha for SELU. Default is 1.6732632423543772848170429916717
scale (float, optional): The value of scale
(must be greater than 1.0)
for SELU. Default is 1.0507009873554804934193349852946
alpha (float, optional): The value of alpha
(must be no less than zero)
for SELU. Default is 1.6732632423543772848170429916717
name (str, optional): Name for the operation (optional, default is None).
For more information, please refer to :ref:`api_guide_Name`.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录