Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
fa12e516
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
提交
fa12e516
编写于
10月 04, 2017
作者:
K
Kavya Srinet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adding the default attribute test case
上级
94855f4a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
50 addition
and
7 deletion
+50
-7
paddle/operators/rmsprop_op.cc
paddle/operators/rmsprop_op.cc
+3
-3
paddle/operators/rmsprop_op.h
paddle/operators/rmsprop_op.h
+3
-3
python/paddle/v2/framework/tests/test_rmsprop_op.py
python/paddle/v2/framework/tests/test_rmsprop_op.py
+44
-1
未找到文件。
paddle/operators/rmsprop_op.cc
浏览文件 @
fa12e516
...
@@ -89,13 +89,13 @@ class RmspropOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -89,13 +89,13 @@ class RmspropOpMaker : public framework::OpProtoAndCheckerMaker {
AddAttr
<
float
>
(
"epsilon"
,
AddAttr
<
float
>
(
"epsilon"
,
"(float, default 1e-10) Constant "
"(float, default 1e-10) Constant "
"for numerical stability."
)
"for numerical stability."
)
.
SetDefault
(
1
e-10
);
.
SetDefault
(
1
.0e-10
f
);
AddAttr
<
float
>
(
"decay"
,
AddAttr
<
float
>
(
"decay"
,
"(float, default 0.9) "
"(float, default 0.9) "
"Discounting factor for coming gradient."
)
"Discounting factor for coming gradient."
)
.
SetDefault
(
0.9
);
.
SetDefault
(
0.9
f
);
AddAttr
<
float
>
(
"momentum"
,
"(float, default 0.0) Constant value"
)
AddAttr
<
float
>
(
"momentum"
,
"(float, default 0.0) Constant value"
)
.
SetDefault
(
0.0
);
.
SetDefault
(
0.0
f
);
AddComment
(
R"DOC(
AddComment
(
R"DOC(
RMSprop
RMSprop
...
...
paddle/operators/rmsprop_op.h
浏览文件 @
fa12e516
...
@@ -28,9 +28,9 @@ template <typename Place, typename T>
...
@@ -28,9 +28,9 @@ template <typename Place, typename T>
class
RmspropOpKernel
:
public
framework
::
OpKernel
<
T
>
{
class
RmspropOpKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
public:
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
auto
param_out
=
ctx
.
Output
<
Tensor
>
(
"ParamOut"
);
auto
*
param_out
=
ctx
.
Output
<
Tensor
>
(
"ParamOut"
);
auto
moment_out
=
ctx
.
Output
<
Tensor
>
(
"MomentOut"
);
auto
*
moment_out
=
ctx
.
Output
<
Tensor
>
(
"MomentOut"
);
auto
mean_square_out
=
ctx
.
Output
<
Tensor
>
(
"MeanSquareOut"
);
auto
*
mean_square_out
=
ctx
.
Output
<
Tensor
>
(
"MeanSquareOut"
);
param_out
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
param_out
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
moment_out
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
moment_out
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
...
...
python/paddle/v2/framework/tests/test_rmsprop_op.py
浏览文件 @
fa12e516
...
@@ -3,7 +3,10 @@ import numpy as np
...
@@ -3,7 +3,10 @@ import numpy as np
from
op_test
import
OpTest
from
op_test
import
OpTest
class
TestRmspropOp
(
OpTest
):
class
TestRmspropOp1
(
OpTest
):
''' Test RMSProp with explicit inputs
'''
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
"rmsprop"
self
.
op_type
=
"rmsprop"
...
@@ -42,5 +45,45 @@ class TestRmspropOp(OpTest):
...
@@ -42,5 +45,45 @@ class TestRmspropOp(OpTest):
self
.
check_output
()
self
.
check_output
()
class
TestRmspropOp2
(
OpTest
):
'''Test RMSProp with defaukt values for attributes
'''
def
setUp
(
self
):
self
.
op_type
=
"rmsprop"
param
=
np
.
random
.
random
((
123
,
321
)).
astype
(
"float32"
)
mean_square
=
np
.
random
.
random
((
123
,
321
)).
astype
(
"float32"
)
learning_rate
=
np
.
array
([
0.01
]).
astype
(
"float32"
)
grad
=
np
.
random
.
random
((
123
,
321
)).
astype
(
"float32"
)
moment
=
np
.
zeros
((
123
,
321
)).
astype
(
"float32"
)
epsilon
=
1.0e-10
decay
=
0.9
momentum
=
0.0
self
.
inputs
=
{
'Param'
:
param
,
'MeanSquare'
:
mean_square
,
'LearningRate'
:
learning_rate
,
'Grad'
:
grad
,
'Moment'
:
moment
,
}
ms_out
=
decay
*
mean_square
+
(
1
-
decay
)
*
grad
*
grad
moment_out
=
momentum
*
moment
+
\
learning_rate
*
grad
/
np
.
sqrt
(
ms_out
+
epsilon
)
param_out
=
param
-
moment_out
self
.
outputs
=
{
'ParamOut'
:
param_out
,
'MomentOut'
:
moment_out
,
'MeanSquareOut'
:
ms_out
}
def
test_check_output
(
self
):
self
.
check_output
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
unittest
.
main
()
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录