Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2ea62d98
提交
2ea62d98
authored
7月 27, 2011
作者:
Razvan Pascanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change the tests to always run in FAST_MODE/DEBUG_MODE
The tests used to fail in FAST_COMPILE because they are suppose to tests optimizations that don't get executed in FAST_COMPILE.
上级
c2a6b64b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
40 行增加
和
12 行删除
+40
-12
test_scan.py
theano/scan_module/tests/test_scan.py
+40
-12
没有找到文件。
theano/scan_module/tests/test_scan.py
浏览文件 @
2ea62d98
...
@@ -1963,6 +1963,10 @@ class T_Scan(unittest.TestCase):
...
@@ -1963,6 +1963,10 @@ class T_Scan(unittest.TestCase):
dtype
=
theano
.
config
.
floatX
),
dtype
=
theano
.
config
.
floatX
),
m
+
trng
.
uniform
(
size
=
[
3
])]
m
+
trng
.
uniform
(
size
=
[
3
])]
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
else
:
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
[
o1
,
o2
],
updates
=
theano
.
scan
(
lm
,
[
o1
,
o2
],
updates
=
theano
.
scan
(
lm
,
sequences
=
x
,
sequences
=
x
,
n_steps
=
None
,
n_steps
=
None
,
...
@@ -1971,7 +1975,7 @@ class T_Scan(unittest.TestCase):
...
@@ -1971,7 +1975,7 @@ class T_Scan(unittest.TestCase):
go_backwards
=
False
)
go_backwards
=
False
)
go1
=
theano
.
tensor
.
grad
(
o1
.
mean
(),
wrt
=
x
)
go1
=
theano
.
tensor
.
grad
(
o1
.
mean
(),
wrt
=
x
)
f
=
theano
.
function
([
x
],
go1
,
updates
=
updates
,
f
=
theano
.
function
([
x
],
go1
,
updates
=
updates
,
allow_input_downcast
=
True
)
allow_input_downcast
=
True
,
mode
=
mode
)
self
.
assertTrue
(
numpy
.
allclose
(
f
([
1
,
2
,
3
]),
2.
/
3
))
self
.
assertTrue
(
numpy
.
allclose
(
f
([
1
,
2
,
3
]),
2.
/
3
))
#theano.printing.debugprint(f, print_type=True)
#theano.printing.debugprint(f, print_type=True)
...
@@ -1997,10 +2001,14 @@ class T_Scan(unittest.TestCase):
...
@@ -1997,10 +2001,14 @@ class T_Scan(unittest.TestCase):
def
sum
(
s
):
def
sum
(
s
):
return
s
+
1
return
s
+
1
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
else
:
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
sx
,
upx
=
theano
.
scan
(
sum
,
sequences
=
[
x
])
sx
,
upx
=
theano
.
scan
(
sum
,
sequences
=
[
x
])
sy
,
upy
=
theano
.
scan
(
sum
,
sequences
=
[
y
])
sy
,
upy
=
theano
.
scan
(
sum
,
sequences
=
[
y
])
f
=
theano
.
function
([
x
,
y
],
[
sx
,
sy
])
f
=
theano
.
function
([
x
,
y
],
[
sx
,
sy
]
,
mode
=
mode
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
scans
=
filter
(
lambda
n
:
isinstance
(
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
),
topo
)
scans
=
filter
(
lambda
n
:
isinstance
(
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
),
topo
)
self
.
assertTrue
(
len
(
scans
)
==
2
)
self
.
assertTrue
(
len
(
scans
)
==
2
)
...
@@ -2008,7 +2016,7 @@ class T_Scan(unittest.TestCase):
...
@@ -2008,7 +2016,7 @@ class T_Scan(unittest.TestCase):
sx
,
upx
=
theano
.
scan
(
sum
,
sequences
=
[
x
],
n_steps
=
2
)
sx
,
upx
=
theano
.
scan
(
sum
,
sequences
=
[
x
],
n_steps
=
2
)
sy
,
upy
=
theano
.
scan
(
sum
,
sequences
=
[
y
],
n_steps
=
3
)
sy
,
upy
=
theano
.
scan
(
sum
,
sequences
=
[
y
],
n_steps
=
3
)
f
=
theano
.
function
([
x
,
y
],
[
sx
,
sy
])
f
=
theano
.
function
([
x
,
y
],
[
sx
,
sy
]
,
mode
=
mode
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
scans
=
filter
(
lambda
n
:
isinstance
(
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
),
topo
)
scans
=
filter
(
lambda
n
:
isinstance
(
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
),
topo
)
self
.
assertTrue
(
len
(
scans
)
==
2
)
self
.
assertTrue
(
len
(
scans
)
==
2
)
...
@@ -2016,7 +2024,7 @@ class T_Scan(unittest.TestCase):
...
@@ -2016,7 +2024,7 @@ class T_Scan(unittest.TestCase):
sx
,
upx
=
theano
.
scan
(
sum
,
sequences
=
[
x
],
n_steps
=
4
)
sx
,
upx
=
theano
.
scan
(
sum
,
sequences
=
[
x
],
n_steps
=
4
)
sy
,
upy
=
theano
.
scan
(
sum
,
sequences
=
[
y
],
n_steps
=
4
)
sy
,
upy
=
theano
.
scan
(
sum
,
sequences
=
[
y
],
n_steps
=
4
)
f
=
theano
.
function
([
x
,
y
],
[
sx
,
sy
])
f
=
theano
.
function
([
x
,
y
],
[
sx
,
sy
]
,
mode
=
mode
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
scans
=
filter
(
lambda
n
:
isinstance
(
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
),
topo
)
scans
=
filter
(
lambda
n
:
isinstance
(
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
),
topo
)
self
.
assertTrue
(
len
(
scans
)
==
1
)
self
.
assertTrue
(
len
(
scans
)
==
1
)
...
@@ -2024,7 +2032,7 @@ class T_Scan(unittest.TestCase):
...
@@ -2024,7 +2032,7 @@ class T_Scan(unittest.TestCase):
sx
,
upx
=
theano
.
scan
(
sum
,
sequences
=
[
x
])
sx
,
upx
=
theano
.
scan
(
sum
,
sequences
=
[
x
])
sy
,
upy
=
theano
.
scan
(
sum
,
sequences
=
[
x
])
sy
,
upy
=
theano
.
scan
(
sum
,
sequences
=
[
x
])
f
=
theano
.
function
([
x
,
y
],
[
sx
,
sy
])
f
=
theano
.
function
([
x
,
y
],
[
sx
,
sy
]
,
mode
=
mode
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
scans
=
filter
(
lambda
n
:
isinstance
(
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
),
topo
)
scans
=
filter
(
lambda
n
:
isinstance
(
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
),
topo
)
self
.
assertTrue
(
len
(
scans
)
==
1
)
self
.
assertTrue
(
len
(
scans
)
==
1
)
...
@@ -2032,7 +2040,7 @@ class T_Scan(unittest.TestCase):
...
@@ -2032,7 +2040,7 @@ class T_Scan(unittest.TestCase):
sx
,
upx
=
theano
.
scan
(
sum
,
sequences
=
[
x
])
sx
,
upx
=
theano
.
scan
(
sum
,
sequences
=
[
x
])
sy
,
upy
=
theano
.
scan
(
sum
,
sequences
=
[
x
],
mode
=
'FAST_COMPILE'
)
sy
,
upy
=
theano
.
scan
(
sum
,
sequences
=
[
x
],
mode
=
'FAST_COMPILE'
)
f
=
theano
.
function
([
x
,
y
],
[
sx
,
sy
])
f
=
theano
.
function
([
x
,
y
],
[
sx
,
sy
]
,
mode
=
mode
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
scans
=
filter
(
lambda
n
:
isinstance
(
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
),
topo
)
scans
=
filter
(
lambda
n
:
isinstance
(
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
),
topo
)
self
.
assertTrue
(
len
(
scans
)
==
2
)
self
.
assertTrue
(
len
(
scans
)
==
2
)
...
@@ -2040,7 +2048,7 @@ class T_Scan(unittest.TestCase):
...
@@ -2040,7 +2048,7 @@ class T_Scan(unittest.TestCase):
sx
,
upx
=
theano
.
scan
(
sum
,
sequences
=
[
x
])
sx
,
upx
=
theano
.
scan
(
sum
,
sequences
=
[
x
])
sy
,
upy
=
theano
.
scan
(
sum
,
sequences
=
[
x
],
truncate_gradient
=
1
)
sy
,
upy
=
theano
.
scan
(
sum
,
sequences
=
[
x
],
truncate_gradient
=
1
)
f
=
theano
.
function
([
x
,
y
],
[
sx
,
sy
])
f
=
theano
.
function
([
x
,
y
],
[
sx
,
sy
]
,
mode
=
mode
)
topo
=
f
.
maker
.
env
.
toposort
()
topo
=
f
.
maker
.
env
.
toposort
()
scans
=
filter
(
lambda
n
:
isinstance
(
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
),
topo
)
scans
=
filter
(
lambda
n
:
isinstance
(
n
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
),
topo
)
self
.
assertTrue
(
len
(
scans
)
==
2
)
self
.
assertTrue
(
len
(
scans
)
==
2
)
...
@@ -2233,6 +2241,10 @@ class T_Scan(unittest.TestCase):
...
@@ -2233,6 +2241,10 @@ class T_Scan(unittest.TestCase):
W2
=
tensor
.
matrix
(
'W2'
)
W2
=
tensor
.
matrix
(
'W2'
)
h0
=
tensor
.
vector
(
'h0'
)
h0
=
tensor
.
vector
(
'h0'
)
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
else
:
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
def
lambda_fn
(
h
,
W1
,
W2
):
def
lambda_fn
(
h
,
W1
,
W2
):
return
tensor
.
dot
(
h
,
W1
+
W2
)
return
tensor
.
dot
(
h
,
W1
+
W2
)
...
@@ -2240,7 +2252,7 @@ class T_Scan(unittest.TestCase):
...
@@ -2240,7 +2252,7 @@ class T_Scan(unittest.TestCase):
non_sequences
=
[
W1
,
W2
],
non_sequences
=
[
W1
,
W2
],
n_steps
=
5
)
n_steps
=
5
)
f
=
theano
.
function
([
h0
,
W1
,
W2
],
o
)
f
=
theano
.
function
([
h0
,
W1
,
W2
],
o
,
mode
=
mode
)
scan_node
=
[
x
for
x
in
f
.
maker
.
env
.
toposort
()
scan_node
=
[
x
for
x
in
f
.
maker
.
env
.
toposort
()
if
isinstance
(
x
.
op
,
if
isinstance
(
x
.
op
,
...
@@ -2261,7 +2273,11 @@ class T_Scan(unittest.TestCase):
...
@@ -2261,7 +2273,11 @@ class T_Scan(unittest.TestCase):
non_sequences
=
[
W1
,
tensor
.
zeros_like
(
W2
)],
non_sequences
=
[
W1
,
tensor
.
zeros_like
(
W2
)],
n_steps
=
5
)
n_steps
=
5
)
f
=
theano
.
function
([
h0
,
W1
,
W2
],
o
)
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
else
:
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
f
=
theano
.
function
([
h0
,
W1
,
W2
],
o
,
mode
=
mode
)
scan_node
=
[
x
for
x
in
f
.
maker
.
env
.
toposort
()
scan_node
=
[
x
for
x
in
f
.
maker
.
env
.
toposort
()
if
isinstance
(
x
.
op
,
if
isinstance
(
x
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
)][
0
]
theano
.
scan_module
.
scan_op
.
Scan
)][
0
]
...
@@ -2286,7 +2302,11 @@ class T_Scan(unittest.TestCase):
...
@@ -2286,7 +2302,11 @@ class T_Scan(unittest.TestCase):
non_sequences
=
[
tensor
.
zeros_like
(
W2
)],
non_sequences
=
[
tensor
.
zeros_like
(
W2
)],
n_steps
=
5
)
n_steps
=
5
)
f
=
theano
.
function
([
h0
,
W1
,
W2
],
o
)
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
else
:
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
f
=
theano
.
function
([
h0
,
W1
,
W2
],
o
,
mode
=
mode
)
scan_node
=
[
x
for
x
in
f
.
maker
.
env
.
toposort
()
scan_node
=
[
x
for
x
in
f
.
maker
.
env
.
toposort
()
if
isinstance
(
x
.
op
,
if
isinstance
(
x
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
)][
0
]
theano
.
scan_module
.
scan_op
.
Scan
)][
0
]
...
@@ -2314,7 +2334,11 @@ class T_Scan(unittest.TestCase):
...
@@ -2314,7 +2334,11 @@ class T_Scan(unittest.TestCase):
non_sequences
=
[
tensor
.
zeros_like
(
W2
)],
non_sequences
=
[
tensor
.
zeros_like
(
W2
)],
n_steps
=
5
)
n_steps
=
5
)
f
=
theano
.
function
([
_h0
,
_W1
,
_W2
],
o
)
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
else
:
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
f
=
theano
.
function
([
_h0
,
_W1
,
_W2
],
o
,
mode
=
mode
)
scan_node
=
[
x
for
x
in
f
.
maker
.
env
.
toposort
()
scan_node
=
[
x
for
x
in
f
.
maker
.
env
.
toposort
()
if
isinstance
(
x
.
op
,
if
isinstance
(
x
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
)][
0
]
theano
.
scan_module
.
scan_op
.
Scan
)][
0
]
...
@@ -2360,7 +2384,11 @@ class T_Scan(unittest.TestCase):
...
@@ -2360,7 +2384,11 @@ class T_Scan(unittest.TestCase):
o2
,
_
=
theano
.
scan
(
lambda
x_t
:(
x_t
+
2
,
theano
.
scan_module
.
until
(
x_t
>
3
)),
o2
,
_
=
theano
.
scan
(
lambda
x_t
:(
x_t
+
2
,
theano
.
scan_module
.
until
(
x_t
>
3
)),
x
)
x
)
f
=
theano
.
function
([
x
],
[
o
,
o2
])
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
else
:
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
f
=
theano
.
function
([
x
],
[
o
,
o2
],
mode
=
mode
)
vx
=
numpy
.
zeros
((
50
,),
dtype
=
theano
.
config
.
floatX
)
vx
=
numpy
.
zeros
((
50
,),
dtype
=
theano
.
config
.
floatX
)
vx
[
23
]
=
4
vx
[
23
]
=
4
out
,
out2
=
f
(
vx
)
out
,
out2
=
f
(
vx
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论