Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9258d425
提交
9258d425
authored
9月 23, 2015
作者:
carriepl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove old code
上级
94702e22
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
0 行增加
和
54 行删除
+0
-54
scan_op.py
theano/scan_module/scan_op.py
+0
-54
没有找到文件。
theano/scan_module/scan_op.py
浏览文件 @
9258d425
...
@@ -1826,43 +1826,6 @@ class Scan(PureOp):
...
@@ -1826,43 +1826,6 @@ class Scan(PureOp):
rval
=
[
gmp
.
get
(
p
,
None
)
for
p
in
diff_inputs
]
rval
=
[
gmp
.
get
(
p
,
None
)
for
p
in
diff_inputs
]
return
rval
return
rval
def
compute_gradient
(
y
,
g_y
):
if
'int'
in
str
(
g_y
.
dtype
):
raise
TypeError
(
"Gradients may never be integers but g_y "
"has type "
+
str
(
g_y
.
type
))
odx
=
get_out_idx
(
self_outputs
.
index
(
y
))
wrt
=
[
x
for
x
in
theano
.
gof
.
graph
.
inputs
([
y
])
if
(
x
in
diff_inputs
)
and
(
connection_pattern
[
get_inp_idx
(
self_inputs
.
index
(
x
))][
odx
])]
gmp
=
OrderedDict
()
for
x
in
wrt
:
try
:
gmp
[
x
]
=
gradient
.
grad
(
cost
=
None
,
known_grads
=
{
y
:
g_y
},
wrt
=
x
,
consider_constant
=
wrt
,
disconnected_inputs
=
'ignore'
,
return_disconnected
=
'None'
)
except
gradient
.
NullTypeGradError
as
e
:
# The gradient wrt that particular input is undefined.
# This is not necessarily an issue, because maybe that
# particular input is not in the path between the
# "cost" and "wrt" of the external, initial call to grad().
# We simply return a Null gradient, forwarding the message.
gmp
[
x
]
=
NullType
((
"This variable is Null because the grad method on the "
"inner graph of the Scan node
%
s returned Null for "
"the corresponding inner input variable. The original "
"message was:
%
s"
%
(
str
(
self
),
exc_message
(
e
))))()
rval
=
[
gmp
.
get
(
p
,
None
)
for
p
in
diff_inputs
]
return
rval
dC_dinps_t
=
[
None
for
inp
in
diff_inputs
]
dC_dinps_t
=
[
None
for
inp
in
diff_inputs
]
disconnected_dC_dinps_t
=
[
True
for
inp
in
diff_inputs
]
disconnected_dC_dinps_t
=
[
True
for
inp
in
diff_inputs
]
dC_dXts
=
[]
dC_dXts
=
[]
...
@@ -1914,22 +1877,6 @@ class Scan(PureOp):
...
@@ -1914,22 +1877,6 @@ class Scan(PureOp):
continue
continue
dC_dXt
=
safe_new
(
dC_douts
[
idx
][
0
])
dC_dXt
=
safe_new
(
dC_douts
[
idx
][
0
])
dC_dXts
.
append
(
dC_dXt
)
dC_dXts
.
append
(
dC_dXt
)
"""
_dC_dinps_t = compute_gradient(Xt, dC_dXt)
for jdx in xrange(len(_dC_dinps_t)):
if dC_dinps_t[jdx] is None:
dC_dinps_t[jdx] = _dC_dinps_t[jdx]
elif isinstance(dC_dinps_t[jdx].type, NullType):
# The accumulated gradient is undefined
pass
elif _dC_dinps_t[jdx]:
if isinstance(_dC_dinps_t[jdx].type, NullType):
# The accumulated gradient is defined, but the new
# term is undefined. The whole thing has to be undefined.
dC_dinps_t[jdx] = _dC_dinps_t[jdx]
else:
dC_dinps_t[jdx] += _dC_dinps_t[jdx]
"""
known_grads
=
{}
known_grads
=
{}
...
@@ -1954,7 +1901,6 @@ class Scan(PureOp):
...
@@ -1954,7 +1901,6 @@ class Scan(PureOp):
dC_dinps_t
=
compute_all_gradients
(
known_grads
)
dC_dinps_t
=
compute_all_gradients
(
known_grads
)
# mask inputs that get no gradients
# mask inputs that get no gradients
for
dx
in
xrange
(
len
(
dC_dinps_t
)):
for
dx
in
xrange
(
len
(
dC_dinps_t
)):
if
not
dC_dinps_t
[
dx
]:
if
not
dC_dinps_t
[
dx
]:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论