Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7b984d13
提交
7b984d13
authored
6月 15, 2015
作者:
--global
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Delete now useless util functions
上级
3556d9ec
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
0 行增加
和
136 行删除
+0
-136
scan_op.py
theano/scan_module/scan_op.py
+0
-136
没有找到文件。
theano/scan_module/scan_op.py
浏览文件 @
7b984d13
...
@@ -1757,142 +1757,6 @@ class Scan(PureOp):
...
@@ -1757,142 +1757,6 @@ class Scan(PureOp):
return
mappings
return
mappings
def
get_inner_oidx_from_outer_oidx
(
self
,
outer_oidx
):
"""Given the index of an outer output, return the indices of the
corresponding inner output(s) in a sequence.
"""
s
=
0
e
=
0
for
p
in
xrange
(
outer_oidx
+
1
):
s
=
e
if
p
<
self
.
n_mit_mot
:
e
+=
len
(
self
.
mitmot_out_taps
()[
p
])
else
:
e
+=
1
return
range
(
s
,
e
)
def
get_inner_iidx_from_outer_iidx
(
self
,
outer_oidx
):
"""Given the index of an outer input, return the indices of the
corresponding inner input(s) in a sequence.
"""
outer_iidx_from_inner_iidx
=
self
.
get_outer_iidx_from_inner_iidx_seq
()
# For every inner input, if the corresponding outer input is the
# desired one, store the index
inner_iidxs
=
[]
for
i
in
xrange
(
len
(
outer_iidx_from_inner_iidx
)):
if
outer_iidx_from_inner_iidx
[
i
]
==
outer_oidx
:
inner_iidxs
.
append
(
i
)
return
inner_iidxs
def
get_outer_iidx_from_outer_oidx_seq
(
self
):
""" Return a sequence where the value at the i-th position is the
index of the outer input corresponding to the i-th outer output
NOTE: mitmots, mitsots, sitsots and shared outputs have corresponding
outer inputs but not nitsots.
"""
nb_outer_outputs
=
(
self
.
n_mit_mot
+
self
.
n_mit_sot
+
self
.
n_sit_sot
+
self
.
n_nit_sot
+
self
.
n_shared_outs
)
result
=
[
-
1
]
*
nb_outer_outputs
# Process mitmots, mitsots and sitsots
input_offset
=
1
+
self
.
n_seqs
output_offset
=
0
for
i
in
range
(
len
(
self
.
tap_array
)):
result
[
output_offset
]
=
input_offset
input_offset
+=
1
output_offset
+=
1
# Process shared inputs/outputs
output_offset
+=
self
.
n_nit_sot
for
i
in
range
(
self
.
n_shared_outs
):
result
[
output_offset
]
=
input_offset
input_offset
+=
1
output_offset
+=
1
return
result
def
get_outer_iidx_from_inner_iidx_seq
(
self
):
""" Return a sequence where the value at the i-th position is the
index of the outer input corresponding to the i-th inner input
"""
output
=
[]
outer_inp_idx
=
1
# First outer input is timestep index, skip it
# Handle sequences inputs
for
i
in
range
(
self
.
info
[
'n_seqs'
]):
output
.
append
(
outer_inp_idx
)
outer_inp_idx
+=
1
# Handle mitmots, mitsots and sitsots inputs
for
input_taps
in
self
.
info
[
'tap_array'
]:
for
tap
in
input_taps
:
output
.
append
(
outer_inp_idx
)
outer_inp_idx
+=
1
# Handle shared inputs
for
i
in
range
(
self
.
info
[
'n_shared_outs'
]):
output
.
append
(
outer_inp_idx
)
outer_inp_idx
+=
1
# No inner input corresponds to the outer nitsot inputs but they still
# need to be counted
outer_inp_idx
+=
self
.
info
[
'n_nit_sot'
]
# Handle non-sequences inputs
nb_nonseqs_inputs
=
len
(
self
.
inputs
)
-
len
(
output
)
for
i
in
range
(
nb_nonseqs_inputs
):
output
.
append
(
outer_inp_idx
)
outer_inp_idx
+=
1
return
output
def
get_inner_oidx_from_inner_iidx_seq
(
self
):
""" Return a sequence where the value at the i-th position is the
sequence containing the indices of all the inner outputs associated
with the same state as the i-th inner input
"""
output
=
[]
inner_out_idx
=
0
# Handle sequence inputs
for
i
in
range
(
self
.
info
[
'n_seqs'
]):
# Inner sequences inputs are not associated with any state
output
.
append
([])
# Handle mitmots, mitsots and sitsots states
for
state_idx
in
range
(
len
(
self
.
info
[
'tap_array'
])):
nb_in_taps
=
len
(
self
.
info
[
'tap_array'
][
state_idx
])
if
state_idx
<
self
.
n_mit_mot
:
nb_out_taps
=
len
(
self
.
mit_mot_out_slices
[
state_idx
])
else
:
nb_out_taps
=
1
for
i
in
range
(
nb_in_taps
):
output
.
append
(
range
(
inner_out_idx
,
inner_out_idx
+
nb_out_taps
))
inner_out_idx
+=
nb_out_taps
# Handle shared inputs
for
i
in
range
(
self
.
info
[
'n_shared_outs'
]):
output
.
append
([
inner_out_idx
])
inner_out_idx
+=
1
# Handle non-sequence inputs
nb_nonseqs_inputs
=
len
(
self
.
inputs
)
-
len
(
output
)
for
i
in
range
(
nb_nonseqs_inputs
):
# Non sequences are not associated with any state
output
.
append
([])
return
output
# GRAD FUNCTION
# GRAD FUNCTION
def
grad
(
self
,
inputs
,
dC_douts
):
def
grad
(
self
,
inputs
,
dC_douts
):
outs
=
self
(
*
inputs
)
outs
=
self
(
*
inputs
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论