Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
07996d4e
提交
07996d4e
authored
4月 03, 2017
作者:
amrithasuresh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated numpy as np
上级
f18302f1
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
23 行增加
和
23 行删除
+23
-23
scan_op.py
theano/scan_module/scan_op.py
+23
-23
没有找到文件。
theano/scan_module/scan_op.py
浏览文件 @
07996d4e
...
...
@@ -54,7 +54,7 @@ import logging
import
time
from
collections
import
OrderedDict
import
numpy
import
numpy
as
np
from
six
import
iteritems
,
integer_types
,
raise_from
from
six.moves
import
xrange
...
...
@@ -193,7 +193,7 @@ class Scan(PureOp):
self
.
info
[
'name'
]
=
self
.
name
# Pre-computing some values to speed up perform
self
.
mintaps
=
[
n
umpy
.
min
(
x
)
for
x
in
self
.
tap_array
]
self
.
mintaps
=
[
n
p
.
min
(
x
)
for
x
in
self
.
tap_array
]
self
.
mintaps
+=
[
0
for
x
in
xrange
(
self
.
n_nit_sot
)]
self
.
seqs_arg_offset
=
1
+
self
.
n_seqs
self
.
shared_arg_offset
=
(
self
.
seqs_arg_offset
+
...
...
@@ -336,7 +336,7 @@ class Scan(PureOp):
the inner function)
"""
assert
n
umpy
.
all
(
isinstance
(
i
,
gof
.
Variable
)
for
i
in
inputs
)
assert
n
p
.
all
(
isinstance
(
i
,
gof
.
Variable
)
for
i
in
inputs
)
# Check that the number of inputs to the Scan node corresponds to
# the number of inputs of the inner function of scan
n_outer_ins
=
len
(
inputs
)
-
len
(
self
.
outer_nitsot
(
inputs
))
-
1
...
...
@@ -901,44 +901,44 @@ class Scan(PureOp):
try
:
if
impl
==
'py'
:
raise
theano
.
gof
.
cmodule
.
MissingGXX
cython_mintaps
=
n
umpy
.
asarray
(
self
.
mintaps
,
dtype
=
'int32'
)
cython_mintaps
=
n
p
.
asarray
(
self
.
mintaps
,
dtype
=
'int32'
)
cython_tap_array_len
=
\
n
umpy
.
asarray
([
len
(
x
)
for
x
in
self
.
tap_array
],
n
p
.
asarray
([
len
(
x
)
for
x
in
self
.
tap_array
],
dtype
=
'int32'
)
if
len
(
self
.
tap_array
)
==
0
:
d1
=
0
else
:
d1
=
n
umpy
.
max
(
cython_tap_array_len
)
d1
=
n
p
.
max
(
cython_tap_array_len
)
d0
=
len
(
self
.
tap_array
)
cython_tap_array
=
n
umpy
.
zeros
((
d0
,
d1
),
dtype
=
'int32'
)
cython_tap_array
=
n
p
.
zeros
((
d0
,
d1
),
dtype
=
'int32'
)
for
_d0
in
xrange
(
d0
):
for
_d1
in
xrange
(
cython_tap_array_len
[
_d0
]):
cython_tap_array
[
_d0
,
_d1
]
=
self
.
tap_array
[
_d0
][
_d1
]
cython_mit_mot_out_nslices
=
\
n
umpy
.
asarray
([
len
(
x
)
for
x
in
self
.
mit_mot_out_slices
],
n
p
.
asarray
([
len
(
x
)
for
x
in
self
.
mit_mot_out_slices
],
dtype
=
'int32'
)
if
len
(
self
.
mit_mot_out_slices
)
==
0
:
d1
=
0
else
:
d1
=
n
umpy
.
max
(
cython_mit_mot_out_nslices
)
d1
=
n
p
.
max
(
cython_mit_mot_out_nslices
)
d0
=
len
(
self
.
mit_mot_out_slices
)
cython_mit_mot_out_slices
=
n
umpy
.
zeros
((
d0
,
d1
),
cython_mit_mot_out_slices
=
n
p
.
zeros
((
d0
,
d1
),
dtype
=
'int32'
)
for
_d0
in
xrange
(
d0
):
for
_d1
in
xrange
(
cython_mit_mot_out_nslices
[
_d0
]):
cython_mit_mot_out_slices
[
_d0
,
_d1
]
=
\
self
.
mit_mot_out_slices
[
_d0
][
_d1
]
cython_vector_seqs
=
n
umpy
.
asarray
(
self
.
vector_seqs
,
cython_vector_seqs
=
n
p
.
asarray
(
self
.
vector_seqs
,
dtype
=
'int32'
)
cython_vector_outs
=
n
umpy
.
asarray
(
self
.
vector_outs
,
cython_vector_outs
=
n
p
.
asarray
(
self
.
vector_outs
,
dtype
=
'int32'
)
cython_mitmots_preallocated
=
n
umpy
.
asarray
(
self
.
mitmots_preallocated
,
cython_mitmots_preallocated
=
n
p
.
asarray
(
self
.
mitmots_preallocated
,
dtype
=
'int32'
)
cython_inps_is_tensor
=
n
umpy
.
asarray
(
self
.
inps_is_tensor
,
cython_inps_is_tensor
=
n
p
.
asarray
(
self
.
inps_is_tensor
,
dtype
=
'int32'
)
cython_outs_is_tensor
=
n
umpy
.
asarray
(
self
.
outs_is_tensor
,
cython_outs_is_tensor
=
n
p
.
asarray
(
self
.
outs_is_tensor
,
dtype
=
'int32'
)
if
hasattr
(
self
,
'destroy_map'
):
...
...
@@ -946,7 +946,7 @@ class Scan(PureOp):
for
x
in
xrange
(
len
(
node
.
outputs
))]
else
:
cython_destroy_map
=
[
0
for
x
in
xrange
(
len
(
node
.
outputs
))]
cython_destroy_map
=
n
umpy
.
asarray
(
cython_destroy_map
,
cython_destroy_map
=
n
p
.
asarray
(
cython_destroy_map
,
dtype
=
'int32'
)
from
.
import
scan_perform_ext
...
...
@@ -2200,9 +2200,9 @@ class Scan(PureOp):
# Seqs
outer_inp_seqs
=
[
x
[::
-
1
]
for
x
in
inputs
[
1
:
1
+
self
.
n_seqs
]]
for
idx
in
xrange
(
self
.
n_mit_mot
+
self
.
n_mit_sot
):
mintap
=
n
umpy
.
min
(
self
.
tap_array
[
idx
])
mintap
=
n
p
.
min
(
self
.
tap_array
[
idx
])
if
idx
<
self
.
n_mit_mot
:
outmaxtap
=
n
umpy
.
max
(
self
.
mitmot_out_taps
()[
idx
])
outmaxtap
=
n
p
.
max
(
self
.
mitmot_out_taps
()[
idx
])
else
:
outmaxtap
=
0
seq
=
outs
[
idx
]
...
...
@@ -2226,7 +2226,7 @@ class Scan(PureOp):
# that.
for
taps
,
x
in
zip
(
self
.
mitsot_taps
(),
self
.
outer_mitsot_outs
(
outs
)):
mintap
=
n
umpy
.
min
(
taps
)
mintap
=
n
p
.
min
(
taps
)
if
hasattr
(
x
[::
-
1
][:
mintap
],
'test_value'
):
assert
(
x
[::
-
1
][:
mintap
]
.
tag
.
test_value
.
shape
[
0
]
==
inputs
[
0
]
.
tag
.
test_value
)
...
...
@@ -2238,7 +2238,7 @@ class Scan(PureOp):
if
hasattr
(
x
[::
-
1
]
.
tag
,
'test_value'
):
assert
(
x
[::
-
1
]
.
tag
.
test_value
.
shape
[
0
]
==
inputs
[
0
]
.
tag
.
test_value
)
outer_inp_seqs
+=
[
x
[::
-
1
][:
n
umpy
.
min
(
taps
)]
outer_inp_seqs
+=
[
x
[::
-
1
][:
n
p
.
min
(
taps
)]
for
taps
,
x
in
zip
(
self
.
mitsot_taps
(),
self
.
outer_mitsot_outs
(
outs
))]
outer_inp_seqs
+=
[
x
[::
-
1
][:
-
1
]
for
x
in
self
.
outer_sitsot_outs
(
outs
)]
...
...
@@ -2726,7 +2726,7 @@ class Scan(PureOp):
b
=
e
e
=
e
+
self
.
n_mit_mot
ib
=
ie
ie
=
ie
+
int
(
n
umpy
.
sum
([
len
(
x
)
for
x
in
ie
=
ie
+
int
(
n
p
.
sum
([
len
(
x
)
for
x
in
self
.
tap_array
[:
self
.
n_mit_mot
]]))
clean_eval_points
=
[]
for
inp
,
evp
in
zip
(
inputs
[
b
:
e
],
eval_points
[
b
:
e
]):
...
...
@@ -2742,7 +2742,7 @@ class Scan(PureOp):
b
=
e
e
=
e
+
self
.
n_mit_sot
ib
=
ie
ie
=
ie
+
int
(
n
umpy
.
sum
([
len
(
x
)
for
x
in
ie
=
ie
+
int
(
n
p
.
sum
([
len
(
x
)
for
x
in
self
.
tap_array
[
self
.
n_mit_mot
:
self
.
n_mit_mot
+
self
.
n_mit_sot
]]))
clean_eval_points
=
[]
...
...
@@ -2795,7 +2795,7 @@ class Scan(PureOp):
inner_other
=
self_inputs
[
ie
:]
+
inner_eval_points
[
ib
:]
# Outputs
n_mit_mot_outs
=
int
(
n
umpy
.
sum
([
len
(
x
)
for
x
in
n_mit_mot_outs
=
int
(
n
p
.
sum
([
len
(
x
)
for
x
in
self
.
mit_mot_out_slices
]))
info
[
'n_mit_mot_outs'
]
=
n_mit_mot_outs
*
2
b
=
0
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论