Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
65d26787
P
Paddle
项目概览
机器未来
/
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看板
提交
65d26787
编写于
7月 28, 2017
作者:
D
dongzhihong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
"add simple net test"
上级
404cc056
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
4 deletion
+12
-4
paddle/framework/backward.cc
paddle/framework/backward.cc
+0
-2
paddle/framework/backward_test.cc
paddle/framework/backward_test.cc
+12
-2
未找到文件。
paddle/framework/backward.cc
浏览文件 @
65d26787
...
...
@@ -86,8 +86,6 @@ static std::shared_ptr<OperatorBase> BackwardImpl(
// travesal subnet/op
for
(
auto
it
=
forwardNet
.
ops_
.
end
();
it
!=
forwardNet
.
ops_
.
begin
();
--
it
)
{
auto
fwd
=
*
it
;
// for (auto& fwd : forwardNet.ops_) {
// auto bwd = Backward(*fwd, no_grad_names);
auto
bwd
=
Backward
(
*
fwd
,
no_grad_names
);
net
->
AddOp
(
bwd
);
for
(
size_t
i
=
0
;
i
<
bwd
->
outputs_
.
size
();
++
i
)
{
...
...
paddle/framework/backward_test.cc
浏览文件 @
65d26787
...
...
@@ -63,10 +63,10 @@ class FcOp : public NetOp {
public:
void
Init
()
override
{
AddOp
(
OpRegistry
::
CreateOp
(
"mul"
,
{
Input
(
"X"
),
Input
(
"W"
)},
{
Output
(
"
before_ac
t"
)},
{}));
{
Output
(
"
mul_ou
t"
)},
{}));
auto
b_name
=
Input
(
"b"
);
if
(
b_name
!=
EMPTY_VAR_NAME
())
{
AddOp
(
OpRegistry
::
CreateOp
(
"rowwise_add"
,
{
Output
(
"
before_ac
t"
),
b_name
},
AddOp
(
OpRegistry
::
CreateOp
(
"rowwise_add"
,
{
Output
(
"
mul_ou
t"
),
b_name
},
{
Output
(
"before_act"
)},
{}));
}
AddOp
(
OpRegistry
::
CreateOp
(
"sigmoid"
,
{
Output
(
"before_act"
)},
...
...
@@ -82,6 +82,7 @@ class FcOpMaker : public OpProtoAndCheckerMaker {
AddInput
(
"X"
,
"x"
);
AddInput
(
"W"
,
"w"
);
AddInput
(
"b"
,
"b"
);
AddOutput
(
"mul_out"
,
"mul output"
).
SetTemporary
();
AddOutput
(
"before_act"
,
"before act"
).
SetTemporary
();
AddOutput
(
"Out"
,
""
);
AddComment
(
""
);
...
...
@@ -140,6 +141,7 @@ TEST(Backward, simple_op_grad) {
auto
fwd
=
f
::
OpRegistry
::
CreateOp
(
"rowwise_add"
,
{
"X"
,
"b"
},
{
"Out"
},
{});
ASSERT_NE
(
fwd
,
nullptr
);
auto
gop
=
f
::
OpRegistry
::
CreateGradOp
(
*
fwd
);
LOG
(
INFO
)
<<
gop
->
DebugString
();
ASSERT_EQ
(
1UL
,
gop
->
inputs_
.
size
());
ASSERT_EQ
(
"Out"
+
f
::
OperatorBase
::
GRAD_VAR_SUFFIX
(),
gop
->
inputs_
[
0
]);
ASSERT_EQ
(
"rowwise_add_grad"
,
gop
->
type_
);
...
...
@@ -151,10 +153,18 @@ TEST(Backward, simple_op_grad) {
// LOG(INFO) << gop->Output("X" + "@GRAD");
}
TEST
(
Backward
,
simple_net_grad
)
{
auto
fwd
=
f
::
OpRegistry
::
CreateOp
(
"rowwise_add"
,
{
"X"
,
"b"
},
{
"Out"
},
{});
ASSERT_NE
(
fwd
,
nullptr
);
auto
gop
=
f
::
Backward
(
*
fwd
,
{});
LOG
(
INFO
)
<<
gop
->
DebugString
();
}
TEST
(
Backward
,
net_fc_backward_normal
)
{
std
::
shared_ptr
<
f
::
OperatorBase
>
fwd
=
f
::
OpRegistry
::
CreateOp
(
"fc"
,
{
"X"
,
"w"
,
"b"
},
{
"out"
},
{});
ASSERT_NE
(
fwd
,
nullptr
);
LOG
(
INFO
)
<<
fwd
->
DebugString
();
std
::
shared_ptr
<
f
::
OperatorBase
>
gop
=
f
::
Backward
(
*
fwd
,
{});
ASSERT_TRUE
(
gop
->
IsNetOp
());
auto
net
=
static_cast
<
f
::
NetOp
*>
(
gop
.
get
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录