Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a6c3723c
提交
a6c3723c
authored
4月 30, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove print in tests.
上级
d12b3db2
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
35 行增加
和
38 行删除
+35
-38
test_debugmode.py
theano/compile/tests/test_debugmode.py
+5
-5
test_function_module.py
theano/compile/tests/test_function_module.py
+4
-4
test_inplace_opt_for_value.py
theano/compile/tests/test_inplace_opt_for_value.py
+15
-18
test_modes.py
theano/compile/tests/test_modes.py
+1
-1
test_vm.py
theano/gof/tests/test_vm.py
+10
-10
没有找到文件。
theano/compile/tests/test_debugmode.py
浏览文件 @
a6c3723c
...
@@ -13,7 +13,7 @@ import unittest
...
@@ -13,7 +13,7 @@ import unittest
def
test0
():
def
test0
():
x
=
theano
.
tensor
.
dvector
()
x
=
theano
.
tensor
.
dvector
()
f
=
theano
.
function
([
x
],
((
2.
*
x
)
+
7
)
/
2.
,
mode
=
debugmode
.
DebugMode
())
f
=
theano
.
function
([
x
],
((
2.
*
x
)
+
7
)
/
2.
,
mode
=
debugmode
.
DebugMode
())
print
f
([
1
,
2
])
f
([
1
,
2
])
class
BROKEN_ON_PURPOSE_Add
(
gof
.
Op
):
class
BROKEN_ON_PURPOSE_Add
(
gof
.
Op
):
...
@@ -671,8 +671,8 @@ class Test_preallocated_output(unittest.TestCase):
...
@@ -671,8 +671,8 @@ class Test_preallocated_output(unittest.TestCase):
f
=
theano
.
function
([
a
,
b
],
out
,
mode
=
'DEBUG_MODE'
)
f
=
theano
.
function
([
a
,
b
],
out
,
mode
=
'DEBUG_MODE'
)
out_val
=
f
(
a_val
,
b_val
)
out_val
=
f
(
a_val
,
b_val
)
print
'out_val ='
,
out_val
#
print 'out_val =', out_val
print
out_val
.
strides
#
print out_val.strides
# Should work for now (0.4.0), because the C thunk does not care
# Should work for now (0.4.0), because the C thunk does not care
# at all of what is in storage_map initially.
# at all of what is in storage_map initially.
...
@@ -682,8 +682,8 @@ class Test_preallocated_output(unittest.TestCase):
...
@@ -682,8 +682,8 @@ class Test_preallocated_output(unittest.TestCase):
f
=
theano
.
function
([
a
,
b
],
out
,
mode
=
'DEBUG_MODE'
)
f
=
theano
.
function
([
a
,
b
],
out
,
mode
=
'DEBUG_MODE'
)
out_val
=
f
(
a_val
,
b_val
)
out_val
=
f
(
a_val
,
b_val
)
print
'out_val ='
,
out_val
#
print 'out_val =', out_val
print
out_val
.
strides
#
print out_val.strides
finally
:
finally
:
config
.
DebugMode
.
check_preallocated_output
=
init_conf_val
config
.
DebugMode
.
check_preallocated_output
=
init_conf_val
theano/compile/tests/test_function_module.py
浏览文件 @
a6c3723c
...
@@ -307,7 +307,7 @@ class T_function(unittest.TestCase):
...
@@ -307,7 +307,7 @@ class T_function(unittest.TestCase):
def
test_constant_output
(
self
):
def
test_constant_output
(
self
):
# Test that if the output is a constant, we respect the theano memory interface
# Test that if the output is a constant, we respect the theano memory interface
f
=
theano
.
function
([],
theano
.
tensor
.
constant
([
4
]))
f
=
theano
.
function
([],
theano
.
tensor
.
constant
([
4
]))
print
f
.
maker
.
env
.
toposort
()
#
print f.maker.env.toposort()
out
=
f
()
out
=
f
()
assert
(
out
==
4
)
.
all
()
assert
(
out
==
4
)
.
all
()
out
[
0
]
=
3
out
[
0
]
=
3
...
@@ -318,7 +318,7 @@ class T_function(unittest.TestCase):
...
@@ -318,7 +318,7 @@ class T_function(unittest.TestCase):
# Test that if the output is a constant and borrow, we respect the theano memory interface
# Test that if the output is a constant and borrow, we respect the theano memory interface
f
=
theano
.
function
([],
Out
(
theano
.
tensor
.
constant
([
4
]),
borrow
=
True
))
f
=
theano
.
function
([],
Out
(
theano
.
tensor
.
constant
([
4
]),
borrow
=
True
))
print
f
.
maker
.
env
.
toposort
()
#
print f.maker.env.toposort()
out
=
f
()
out
=
f
()
assert
(
out
==
4
)
.
all
()
assert
(
out
==
4
)
.
all
()
out
[
0
]
=
3
out
[
0
]
=
3
...
@@ -412,8 +412,8 @@ class T_picklefunction(unittest.TestCase):
...
@@ -412,8 +412,8 @@ class T_picklefunction(unittest.TestCase):
self
.
assertFalse
(
x
in
g
.
container
)
self
.
assertFalse
(
x
in
g
.
container
)
self
.
assertFalse
(
x
in
g
.
value
)
self
.
assertFalse
(
x
in
g
.
value
)
self
.
assertTrue
(
len
(
f
.
defaults
)
==
len
(
g
.
defaults
))
self
.
assertTrue
(
len
(
f
.
defaults
)
==
len
(
g
.
defaults
))
print
'f.defaults =
%
s'
%
(
f
.
defaults
,
)
#
print 'f.defaults = %s' % (f.defaults, )
print
'g.defaults =
%
s'
%
(
g
.
defaults
,
)
#
print 'g.defaults = %s' % (g.defaults, )
self
.
assertTrue
(
all
([
f_req
==
g_req
and
f_feed
==
g_feed
and
self
.
assertTrue
(
all
([
f_req
==
g_req
and
f_feed
==
g_feed
and
f_val
==
g_val
f_val
==
g_val
for
((
f_req
,
f_feed
,
f_val
),
(
g_req
,
g_feed
,
g_val
))
in
zip
(
for
((
f_req
,
f_feed
,
f_val
),
(
g_req
,
g_feed
,
g_val
))
in
zip
(
...
...
theano/compile/tests/test_inplace_opt_for_value.py
浏览文件 @
a6c3723c
...
@@ -187,7 +187,7 @@ class ExampleRNN(Module):
...
@@ -187,7 +187,7 @@ class ExampleRNN(Module):
self
.
minimizer
=
minimizer
([
x
,
y
],
self
.
cost
,
self
.
params
)
self
.
minimizer
=
minimizer
([
x
,
y
],
self
.
cost
,
self
.
params
)
def
_instance_initialize
(
self
,
obj
):
def
_instance_initialize
(
self
,
obj
):
print
'INITIALIZE EXAMPLE RNN'
#
print 'INITIALIZE EXAMPLE RNN'
n_vis
=
self
.
n_vis
n_vis
=
self
.
n_vis
rng
=
N
.
random
.
RandomState
(
unittest_tools
.
fetch_seed
(
2342
))
rng
=
N
.
random
.
RandomState
(
unittest_tools
.
fetch_seed
(
2342
))
...
@@ -214,7 +214,7 @@ def test_example_rnn():
...
@@ -214,7 +214,7 @@ def test_example_rnn():
LAG
=
4
LAG
=
4
y
[
LAG
:]
=
x
[:
-
LAG
,
0
:
n_out
]
y
[
LAG
:]
=
x
[:
-
LAG
,
0
:
n_out
]
if
1
:
if
0
:
for
i
,
node
in
enumerate
(
rnn
.
minimizer
.
step_cost
.
maker
.
env
.
toposort
()):
for
i
,
node
in
enumerate
(
rnn
.
minimizer
.
step_cost
.
maker
.
env
.
toposort
()):
print
i
,
node
print
i
,
node
...
@@ -223,10 +223,7 @@ def test_example_rnn():
...
@@ -223,10 +223,7 @@ def test_example_rnn():
niter
=
30
niter
=
30
for
i
in
xrange
(
niter
):
for
i
in
xrange
(
niter
):
if
i
%
100
==
0
:
rnn
.
minimizer
.
step_cost
(
x
,
y
)
print
i
,
rnn
.
minimizer
.
step_cost
(
x
,
y
),
rnn
.
minimizer
.
stepsize
else
:
rnn
.
minimizer
.
step_cost
(
x
,
y
)
if
theano
.
config
.
mode
==
'DEBUG_MODE'
:
if
theano
.
config
.
mode
==
'DEBUG_MODE'
:
assert
rnn
.
minimizer
.
step_cost
(
x
,
y
)
<
-.
9
#it starts around -.28
assert
rnn
.
minimizer
.
step_cost
(
x
,
y
)
<
-.
9
#it starts around -.28
else
:
else
:
...
@@ -258,7 +255,7 @@ def test_WEIRD_STUFF():
...
@@ -258,7 +255,7 @@ def test_WEIRD_STUFF():
# rnn2 = rnn_module1.make(mode=Mode('c|py', 'fast_run').excluding("inplace_opt"))#work
# rnn2 = rnn_module1.make(mode=Mode('c|py', 'fast_run').excluding("inplace_opt"))#work
# rnn2 = rnn_module1.make(mode=Mode('py', 'fast_run'))#fail
# rnn2 = rnn_module1.make(mode=Mode('py', 'fast_run'))#fail
m
=
Mode
(
'py'
,
'fast_run'
)
m
=
Mode
(
'py'
,
'fast_run'
)
for
n
in
m
.
optimizer
:
print
n
.
name
#
for n in m.optimizer: print n.name
if
0
:
if
0
:
topo1
=
rnn1
.
minimizer
.
step_cost
.
maker
.
env
.
toposort
()
topo1
=
rnn1
.
minimizer
.
step_cost
.
maker
.
env
.
toposort
()
...
@@ -266,7 +263,7 @@ def test_WEIRD_STUFF():
...
@@ -266,7 +263,7 @@ def test_WEIRD_STUFF():
for
i
in
range
(
len
(
topo1
)):
for
i
in
range
(
len
(
topo1
)):
print
'1'
,
i
,
topo1
[
i
]
print
'1'
,
i
,
topo1
[
i
]
print
'2'
,
i
,
topo2
[
i
]
print
'2'
,
i
,
topo2
[
i
]
if
1
:
if
0
:
topo1
=
rnn1
.
minimizer
.
step
.
maker
.
env
.
toposort
()
topo1
=
rnn1
.
minimizer
.
step
.
maker
.
env
.
toposort
()
topo2
=
rnn2
.
minimizer
.
step
.
maker
.
env
.
toposort
()
topo2
=
rnn2
.
minimizer
.
step
.
maker
.
env
.
toposort
()
for
i
in
range
(
len
(
topo1
)):
for
i
in
range
(
len
(
topo1
)):
...
@@ -274,10 +271,10 @@ def test_WEIRD_STUFF():
...
@@ -274,10 +271,10 @@ def test_WEIRD_STUFF():
print
'2'
,
i
,
topo2
[
i
]
print
'2'
,
i
,
topo2
[
i
]
import
theano.printing
import
theano.printing
print
len
(
rnn1
.
minimizer
.
step
.
maker
.
inputs
)
#
print len(rnn1.minimizer.step.maker.inputs)
print
len
(
rnn2
.
minimizer
.
step
.
maker
.
inputs
)
#
print len(rnn2.minimizer.step.maker.inputs)
print
rnn1
.
minimizer
.
step
.
maker
.
inputs
#
print rnn1.minimizer.step.maker.inputs
print
rnn2
.
minimizer
.
step
.
maker
.
inputs
#
print rnn2.minimizer.step.maker.inputs
...
@@ -293,15 +290,15 @@ def test_WEIRD_STUFF():
...
@@ -293,15 +290,15 @@ def test_WEIRD_STUFF():
niter
=
3
niter
=
3
for
i
in
xrange
(
niter
):
for
i
in
xrange
(
niter
):
print
rnn1
.
minimizer
.
step_cost
(
x
,
y
)
#
print rnn1.minimizer.step_cost(x, y)
print
rnn2
.
minimizer
.
step_cost
(
x
,
y
)
#
print rnn2.minimizer.step_cost(x, y)
# assert rnn1.n_vis != rnn2.n_vis or slef.n_hid != rnn2.n_hid or rnn1.n_out != rnn2.n_out
# assert rnn1.n_vis != rnn2.n_vis or slef.n_hid != rnn2.n_hid or rnn1.n_out != rnn2.n_out
assert
(
N
.
abs
(
rnn1
.
z0
-
rnn2
.
z0
)
<
1e-8
)
.
all
()
assert
(
N
.
abs
(
rnn1
.
z0
-
rnn2
.
z0
)
<
1e-8
)
.
all
()
print
(
N
.
abs
(
rnn1
.
w
-
rnn2
.
w
)
<
1e-8
)
.
all
()
#
print (N.abs(rnn1.w-rnn2.w)<1e-8).all()
print
(
N
.
abs
(
rnn1
.
w
-
rnn2
.
w
))
#
print (N.abs(rnn1.w-rnn2.w))
print
rnn1
.
w
#
print rnn1.w
print
rnn2
.
w
#
print rnn2.w
assert
(
N
.
abs
(
rnn1
.
w
-
rnn2
.
w
)
<
1e-8
)
.
all
()
assert
(
N
.
abs
(
rnn1
.
w
-
rnn2
.
w
)
<
1e-8
)
.
all
()
# assert b
# assert b
...
...
theano/compile/tests/test_modes.py
浏览文件 @
a6c3723c
...
@@ -32,7 +32,7 @@ class T_bunch_of_modes(unittest.TestCase):
...
@@ -32,7 +32,7 @@ class T_bunch_of_modes(unittest.TestCase):
# test that it runs something
# test that it runs something
f
([[
1
,
2
],
[
3
,
4
]],
[
5
,
6
])
f
([[
1
,
2
],
[
3
,
4
]],
[
5
,
6
])
linker_classes_involved
.
append
(
f
.
maker
.
mode
.
linker
.
__class__
)
linker_classes_involved
.
append
(
f
.
maker
.
mode
.
linker
.
__class__
)
print
'MODE:'
,
mode
,
f
.
maker
.
mode
.
linker
,
'stop'
#
print 'MODE:', mode, f.maker.mode.linker, 'stop'
# regression check:
# regression check:
# there should be
# there should be
# - VM_Linker
# - VM_Linker
...
...
theano/gof/tests/test_vm.py
浏览文件 @
a6c3723c
...
@@ -74,10 +74,10 @@ def test_speed():
...
@@ -74,10 +74,10 @@ def test_speed():
numpy_version
(
x
,
steps_a
)
numpy_version
(
x
,
steps_a
)
t0
=
time
.
time
()
t0
=
time
.
time
()
print
numpy_version
(
x
,
steps_a
)
#
print numpy_version(x, steps_a)
t1
=
time
.
time
()
t1
=
time
.
time
()
t2
=
time
.
time
()
t2
=
time
.
time
()
print
numpy_version
(
x
,
steps_b
)
#
print numpy_version(x, steps_b)
t3
=
time
.
time
()
t3
=
time
.
time
()
t_a
=
t1
-
t0
t_a
=
t1
-
t0
t_b
=
t3
-
t2
t_b
=
t3
-
t2
...
@@ -103,15 +103,15 @@ def test_speed():
...
@@ -103,15 +103,15 @@ def test_speed():
#profile='f_b speed test %s'%name,
#profile='f_b speed test %s'%name,
)
)
print
f_a
([
2.0
,
3.0
])
f_a
([
2.0
,
3.0
])
t0
=
time
.
time
()
t0
=
time
.
time
()
print
f_a
([
2.0
,
3.0
])
f_a
([
2.0
,
3.0
])
t1
=
time
.
time
()
t1
=
time
.
time
()
print
f_b
([
2.0
,
3.0
])
f_b
([
2.0
,
3.0
])
t2
=
time
.
time
()
t2
=
time
.
time
()
print
f_b
([
2.0
,
3.0
])
f_b
([
2.0
,
3.0
])
t3
=
time
.
time
()
t3
=
time
.
time
()
t_a
=
t1
-
t0
t_a
=
t1
-
t0
...
@@ -155,15 +155,15 @@ def test_speed_lazy():
...
@@ -155,15 +155,15 @@ def test_speed_lazy():
#profile='f_b lazy ifelse %s'%name,
#profile='f_b lazy ifelse %s'%name,
)
)
print
f_a
([
2.0
])
f_a
([
2.0
])
t0
=
time
.
time
()
t0
=
time
.
time
()
print
f_a
([
2.0
])
f_a
([
2.0
])
t1
=
time
.
time
()
t1
=
time
.
time
()
print
f_b
([
2.0
])
f_b
([
2.0
])
t2
=
time
.
time
()
t2
=
time
.
time
()
print
f_b
([
2.0
])
f_b
([
2.0
])
t3
=
time
.
time
()
t3
=
time
.
time
()
t_a
=
t1
-
t0
t_a
=
t1
-
t0
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论