Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
78ac9eb5
提交
78ac9eb5
authored
8月 30, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pep8 for scan_op
上级
07f7da05
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
8 行增加
和
8 行删除
+8
-8
scan_op.py
theano/scan_module/scan_op.py
+8
-8
没有找到文件。
theano/scan_module/scan_op.py
浏览文件 @
78ac9eb5
...
@@ -433,7 +433,7 @@ class Scan(PureOp):
...
@@ -433,7 +433,7 @@ class Scan(PureOp):
aux_txt
+=
str
(
k
)
+
','
aux_txt
+=
str
(
k
)
+
','
aux_txt
+=
'},
%
s,
%
s}'
aux_txt
+=
'},
%
s,
%
s}'
else
:
else
:
aux_txt
+=
'{
%
s,
%
s}'
aux_txt
+=
'{
%
s,
%
s}'
aux_txt
=
aux_txt
%
(
name
,
gpu_str
,
str
(
self
.
name
))
aux_txt
=
aux_txt
%
(
name
,
gpu_str
,
str
(
self
.
name
))
return
aux_txt
return
aux_txt
...
@@ -1164,16 +1164,15 @@ class Scan(PureOp):
...
@@ -1164,16 +1164,15 @@ class Scan(PureOp):
### GRAD FUNCTION
### GRAD FUNCTION
def
grad
(
self
,
args
,
g_outs
):
def
grad
(
self
,
args
,
g_outs
):
# This discards information about whether incoming gradients are 0
# This discards information about whether incoming gradients are 0
# or disconnected from the cost
# or disconnected from the cost
# TODO: upgrade scan op to report disconnection correctly
# TODO: upgrade scan op to report disconnection correctly
def
strip_disconnected
(
g
):
def
strip_disconnected
(
g
):
if
isinstance
(
g
.
type
,
DisconnectedType
):
if
isinstance
(
g
.
type
,
DisconnectedType
):
return
None
return
None
return
g
return
g
g_outs
=
[
strip_disconnected
(
g
)
for
g
in
g_outs
]
g_outs
=
[
strip_disconnected
(
g
)
for
g
in
g_outs
]
# 1. forward pass - get the outputs after applying scan
# 1. forward pass - get the outputs after applying scan
scan_outputs
=
self
(
*
args
)
scan_outputs
=
self
(
*
args
)
...
@@ -1538,12 +1537,12 @@ class Scan(PureOp):
...
@@ -1538,12 +1537,12 @@ class Scan(PureOp):
gradients
+=
[
x
[::
-
1
]
for
x
in
outputs
[:
end
]]
gradients
+=
[
x
[::
-
1
]
for
x
in
outputs
[:
end
]]
start
=
len
(
gradients
)
start
=
len
(
gradients
)
gradients
+=
[
gradients
+=
[
grad_undefined
(
self
,
x
+
start
,
args
[
x
+
start
],
grad_undefined
(
self
,
x
+
start
,
args
[
x
+
start
],
'Shared Variable with update'
)
'Shared Variable with update'
)
for
x
in
xrange
(
self
.
n_shared_outs
)]
for
x
in
xrange
(
self
.
n_shared_outs
)]
start
=
len
(
gradients
)
start
=
len
(
gradients
)
gradients
+=
[
gradients
+=
[
grad_undefined
(
self
,
x
+
start
,
args
[
x
+
start
],
grad_undefined
(
self
,
x
+
start
,
args
[
x
+
start
],
'Dimension of memory buffer for output'
)
'Dimension of memory buffer for output'
)
for
x
in
xrange
(
self
.
n_nit_sot
)]
for
x
in
xrange
(
self
.
n_nit_sot
)]
begin
=
end
begin
=
end
...
@@ -1569,7 +1568,8 @@ class Scan(PureOp):
...
@@ -1569,7 +1568,8 @@ class Scan(PureOp):
rop_self_outputs
=
self_outputs
rop_self_outputs
=
self_outputs
if
self
.
info
[
'n_shared_outs'
]
>
0
:
if
self
.
info
[
'n_shared_outs'
]
>
0
:
rop_self_outputs
=
rop_self_outputs
[:
-
self
.
info
[
'n_shared_outs'
]]
rop_self_outputs
=
rop_self_outputs
[:
-
self
.
info
[
'n_shared_outs'
]]
rop_outs
=
tensor
.
Rop
(
rop_self_outputs
,
rop_of_inputs
,
inner_eval_points
)
rop_outs
=
tensor
.
Rop
(
rop_self_outputs
,
rop_of_inputs
,
inner_eval_points
)
if
type
(
rop_outs
)
not
in
(
list
,
tuple
):
if
type
(
rop_outs
)
not
in
(
list
,
tuple
):
rop_outs
=
[
rop_outs
]
rop_outs
=
[
rop_outs
]
# Step 2. Figure out what corresponds to what in the scan
# Step 2. Figure out what corresponds to what in the scan
...
@@ -1760,7 +1760,7 @@ class Scan(PureOp):
...
@@ -1760,7 +1760,7 @@ class Scan(PureOp):
b
=
e
+
self
.
n_nit_sot
b
=
e
+
self
.
n_nit_sot
e
=
e
+
self
.
n_nit_sot
*
2
e
=
e
+
self
.
n_nit_sot
*
2
final_outs
+=
outputs
[
b
:
e
]
final_outs
+=
outputs
[
b
:
e
]
final_outs
+=
[
None
]
*
self
.
n_shared_outs
final_outs
+=
[
None
]
*
self
.
n_shared_outs
return
final_outs
return
final_outs
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论