Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f2e76008
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
f2e76008
编写于
12月 15, 2017
作者:
F
fengjiayi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
9956d5f7
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
23 addition
and
2 deletion
+23
-2
python/paddle/v2/fluid/backward.py
python/paddle/v2/fluid/backward.py
+19
-0
python/paddle/v2/fluid/framework.py
python/paddle/v2/fluid/framework.py
+4
-2
未找到文件。
python/paddle/v2/fluid/backward.py
浏览文件 @
f2e76008
from
paddle.v2.fluid
import
framework
as
framework
from
paddle.v2.fluid
import
framework
as
framework
from
.
import
core
__all__
=
[
'append_backward_ops'
]
__all__
=
[
'append_backward_ops'
]
def
backward_impl
(
block
,
target_block
,
no_grad_set
,
grad_to_var
,
callback
):
grad_op_descs
=
[]
program
=
block
.
program
for
each_op
in
block
.
ops
:
grad_sub_block_list
=
[]
if
each_op
.
has_attr
(
"sub_block"
):
sub_block_idx
=
each_op
.
block_attr
(
"sub_block"
)
sub_block
=
program
.
block
(
sub_block_idx
)
grad_sub_block
=
program
.
create_block
(
parent_idx
=
sub_block_idx
)
backward_impl
(
sub_block
,
grad_sub_block
,
no_grad_set
,
grad_to_var
,
callback
)
grad_sub_block_list
.
append
(
grad_sub_block
)
grad_op_desc
=
core
.
get_grad_op_desc
(
each_op
.
desc
,
no_grad_set
[
block
.
idx
],
grad_to_var
,
grad_sub_block_list
)
grad_op_descs
.
append
(
grad_op_desc
)
def
append_backward_ops
(
loss
,
parameter_list
=
None
,
no_grad_set
=
None
):
def
append_backward_ops
(
loss
,
parameter_list
=
None
,
no_grad_set
=
None
):
"""
"""
Create and add gradient Operators in BlockDesc to compute
Create and add gradient Operators in BlockDesc to compute
...
...
python/paddle/v2/fluid/framework.py
浏览文件 @
f2e76008
...
@@ -806,9 +806,11 @@ class Program(object):
...
@@ -806,9 +806,11 @@ class Program(object):
self
.
sync_with_cpp
()
self
.
sync_with_cpp
()
return
param_to_grad_info
return
param_to_grad_info
def
create_block
(
self
):
def
create_block
(
self
,
parent_idx
=
None
):
new_block_idx
=
len
(
self
.
blocks
)
new_block_idx
=
len
(
self
.
blocks
)
self
.
desc
.
append_block
(
self
.
current_block
().
desc
)
parent
=
self
.
current_block
()
if
parent_idx
is
None
else
self
.
block
(
parent_idx
)
self
.
desc
.
append_block
(
parent
.
desc
)
self
.
current_block_idx
=
new_block_idx
self
.
current_block_idx
=
new_block_idx
self
.
blocks
.
append
(
Block
(
self
,
self
.
current_block_idx
))
self
.
blocks
.
append
(
Block
(
self
,
self
.
current_block_idx
))
return
self
.
current_block
()
return
self
.
current_block
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录