Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
da41c9da
提交
da41c9da
authored
9月 05, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rearranged access_term_cache to have a section clearly devoted to type
checking
上级
ccdcc319
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
7 行删除
+11
-7
gradient.py
theano/gradient.py
+11
-7
没有找到文件。
theano/gradient.py
浏览文件 @
da41c9da
...
@@ -716,11 +716,12 @@ def _populate_grad_dict(var_to_node_to_idx,
...
@@ -716,11 +716,12 @@ def _populate_grad_dict(var_to_node_to_idx,
# must convert to list in case the op returns a tuple
# must convert to list in case the op returns a tuple
# we won't be able to post-process out the Nones if it does that
# we won't be able to post-process out the Nones if it does that
term_dict
[
node
]
=
list
(
input_grads
)
input_grads
=
list
(
input_grads
)
for
i
in
xrange
(
len
(
term_dict
[
node
])):
#Do type checking on the result
for
i
,
term
in
enumerate
(
input_grads
):
if
term
_dict
[
node
][
i
]
is
None
:
if
term
is
None
:
# we don't know what None means. in the past it has been
# we don't know what None means. in the past it has been
# used to
# used to
# mean undefined, zero, or disconnected. So for now we
# mean undefined, zero, or disconnected. So for now we
...
@@ -730,10 +731,10 @@ def _populate_grad_dict(var_to_node_to_idx,
...
@@ -730,10 +731,10 @@ def _populate_grad_dict(var_to_node_to_idx,
# eventually we should disallow this
# eventually we should disallow this
# return type and force all ops
# return type and force all ops
# to return the correct thing
# to return the correct thing
#
raise AssertionError
('%s returned None for' +\
#
raise AssertionError(
('%s returned None for' +\
# ' a gradient term, '
# ' a gradient term, '
# 'this is prohibited' % node.op)
# 'this is prohibited'
)
% node.op)
term_dict
[
node
]
[
i
]
=
node
.
inputs
[
i
]
.
zeros_like
()
input_grads
[
i
]
=
node
.
inputs
[
i
]
.
zeros_like
()
if
warn_type
:
if
warn_type
:
g_r_type
=
term_dict
[
node
][
i
]
.
type
g_r_type
=
term_dict
[
node
][
i
]
.
type
...
@@ -744,6 +745,9 @@ def _populate_grad_dict(var_to_node_to_idx,
...
@@ -744,6 +745,9 @@ def _populate_grad_dict(var_to_node_to_idx,
'for input
%
i of type (
%
s)'
,
'for input
%
i of type (
%
s)'
,
node
.
op
,
g_r_type
,
i
,
r_type
)
node
.
op
,
g_r_type
,
i
,
r_type
)
#cache the result
term_dict
[
node
]
=
list
(
input_grads
)
return
term_dict
[
node
]
return
term_dict
[
node
]
# populate grad_dict[var] and return it
# populate grad_dict[var] and return it
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论