Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
fcb2ac60
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
fcb2ac60
编写于
9月 04, 2020
作者:
H
huangjun12
提交者:
GitHub
9月 04, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix alpha dropout bug when p=1, test=develop (#26977)
上级
9e4fe923
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
12 addition
and
1 deletion
+12
-1
python/paddle/fluid/tests/unittests/test_dropout_op.py
python/paddle/fluid/tests/unittests/test_dropout_op.py
+10
-1
python/paddle/nn/functional/common.py
python/paddle/nn/functional/common.py
+2
-0
未找到文件。
python/paddle/fluid/tests/unittests/test_dropout_op.py
浏览文件 @
fcb2ac60
...
...
@@ -43,7 +43,7 @@ class TestDropoutOp(OpTest):
class
TestDropoutOpInput1d
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"dropout"
self
.
inputs
=
{
'X'
:
np
.
random
.
random
((
2000
)).
astype
(
"float32"
)}
self
.
inputs
=
{
'X'
:
np
.
random
.
random
((
2000
,
)).
astype
(
"float32"
)}
self
.
attrs
=
{
'dropout_prob'
:
0.0
,
'fix_seed'
:
True
,
'is_test'
:
False
}
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
],
...
...
@@ -672,9 +672,11 @@ class TestAlphaDropoutFAPI(unittest.TestCase):
res1
=
paddle
.
nn
.
functional
.
alpha_dropout
(
x
=
input
,
p
=
0.
)
res2
=
paddle
.
nn
.
functional
.
alpha_dropout
(
x
=
input
,
p
=
0.
,
training
=
False
)
res3
=
paddle
.
nn
.
functional
.
alpha_dropout
(
x
=
input
,
p
=
1.
)
in_np
=
np
.
random
.
random
([
40
,
40
]).
astype
(
"float32"
)
res_np
=
in_np
res_np3
=
np
.
zeros_like
(
in_np
)
exe
=
fluid
.
Executor
(
place
)
res_list
=
[
res1
,
res2
]
...
...
@@ -683,6 +685,10 @@ class TestAlphaDropoutFAPI(unittest.TestCase):
feed
=
{
"input"
:
in_np
},
fetch_list
=
[
res
])
self
.
assertTrue
(
np
.
allclose
(
fetches
[
0
],
res_np
))
fetches
=
exe
.
run
(
fluid
.
default_main_program
(),
feed
=
{
"input"
:
in_np
},
fetch_list
=
[
res3
])
self
.
assertTrue
(
np
.
allclose
(
fetches
[
0
],
res_np3
))
def
test_static
(
self
):
for
place
in
self
.
places
:
...
...
@@ -693,15 +699,18 @@ class TestAlphaDropoutFAPI(unittest.TestCase):
with
fluid
.
dygraph
.
guard
(
place
):
in_np
=
np
.
random
.
random
([
40
,
40
]).
astype
(
"float32"
)
res_np
=
in_np
res_np3
=
np
.
zeros_like
(
in_np
)
input
=
fluid
.
dygraph
.
to_variable
(
in_np
)
res1
=
paddle
.
nn
.
functional
.
alpha_dropout
(
x
=
input
,
p
=
0.
)
res2
=
paddle
.
nn
.
functional
.
alpha_dropout
(
x
=
input
,
p
=
0.
,
training
=
False
)
res3
=
paddle
.
nn
.
functional
.
alpha_dropout
(
x
=
input
,
p
=
1.
)
res_list
=
[
res1
,
res2
]
for
res
in
res_list
:
self
.
assertTrue
(
np
.
allclose
(
res
.
numpy
(),
res_np
))
self
.
assertTrue
(
np
.
allclose
(
res3
.
numpy
(),
res_np3
))
class
TestAlphaDropoutFAPIError
(
unittest
.
TestCase
):
...
...
python/paddle/nn/functional/common.py
浏览文件 @
fcb2ac60
...
...
@@ -1091,6 +1091,8 @@ def alpha_dropout(x, p=0.5, training=True, name=None):
'alpha_dropout'
)
if
training
:
if
p
==
1
:
return
layers
.
scale
(
x
,
scale
=
0.
)
#get transformation params
alpha
=
1.6732632423543772848170429916717
scale
=
1.0507009873554804934193349852946
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录