Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d85e6795
提交
d85e6795
authored
9月 05, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed bugs introduced by recent commits
上级
896fdba3
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
6 行增加
和
7 行删除
+6
-7
gradient.py
theano/gradient.py
+6
-7
没有找到文件。
theano/gradient.py
浏览文件 @
d85e6795
...
@@ -668,8 +668,9 @@ def _populate_grad_dict(var_to_node_to_idx,
...
@@ -668,8 +668,9 @@ def _populate_grad_dict(var_to_node_to_idx,
# its inputs' gradients
# its inputs' gradients
term_dict
=
{}
term_dict
=
{}
# populate term_dict[node] and return it
def
access_term_cache
(
node
):
def
access_term_cache
(
node
):
""" Populates term_dict[node] and returns it """
if
node
not
in
term_dict
:
if
node
not
in
term_dict
:
inputs
=
node
.
inputs
inputs
=
node
.
inputs
...
@@ -684,15 +685,13 @@ def _populate_grad_dict(var_to_node_to_idx,
...
@@ -684,15 +685,13 @@ def _populate_grad_dict(var_to_node_to_idx,
# list of bools indicating if each input is connected to the cost
# list of bools indicating if each input is connected to the cost
inputs_connected
=
[
inputs_connected
=
[
[
input_to_output
and
output_to_cost
for
(
True
in
[
input_to_output
and
output_to_cost
for
input_to_output
,
output_to_cost
in
input_to_output
,
output_to_cost
in
zip
(
input_to_outputs
,
outputs_connected
)
]
for
zip
(
input_to_outputs
,
outputs_connected
)
]
)
for
input_to_outputs
in
connection_pattern
input_to_outputs
in
connection_pattern
]
]
all_inputs_disconnected
=
not
(
True
in
inputs_connected
)
if
True
in
inputs_connected
:
if
all_inputs_disconnected
:
# At least one input of this op is connected to the cost so we must
# At least one input of this op is connected to the cost so we must
# call the op's grad method
# call the op's grad method
...
@@ -763,7 +762,7 @@ def _populate_grad_dict(var_to_node_to_idx,
...
@@ -763,7 +762,7 @@ def _populate_grad_dict(var_to_node_to_idx,
node
.
op
,
g_r_type
,
i
,
r_type
)
node
.
op
,
g_r_type
,
i
,
r_type
)
#cache the result
#cache the result
term_dict
[
node
]
=
list
(
input_grads
)
term_dict
[
node
]
=
input_grads
return
term_dict
[
node
]
return
term_dict
[
node
]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论