Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0156327d
提交
0156327d
authored
4月 30, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove print in tests.
上级
a6c3723c
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
24 行增加
和
43 行删除
+24
-43
test_builders.py
theano/compile/tests/test_builders.py
+3
-3
test_debugmode.py
theano/compile/tests/test_debugmode.py
+5
-5
test_misc.py
theano/compile/tests/test_misc.py
+2
-2
test_module.py
theano/compile/tests/test_module.py
+13
-11
test_pfunc.py
theano/compile/tests/test_pfunc.py
+1
-22
没有找到文件。
theano/compile/tests/test_builders.py
浏览文件 @
0156327d
...
...
@@ -22,9 +22,9 @@ class T_OpFromGraph(unittest.TestCase):
xv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
print
function
,
function
.
__module__
print
fn
.
maker
.
env
.
toposort
()
print
fn
(
xv
,
yv
,
zv
)
#
print function, function.__module__
#
print fn.maker.env.toposort()
fn
(
xv
,
yv
,
zv
)
assert
numpy
.
all
(
8.0
==
fn
(
xv
,
yv
,
zv
))
assert
numpy
.
all
(
8.0
==
fn
(
xv
,
yv
,
zv
))
...
...
theano/compile/tests/test_debugmode.py
浏览文件 @
0156327d
...
...
@@ -211,7 +211,7 @@ def test_badclinkeroutput():
try
:
f_inconsistent
([
1.0
,
2.0
,
3.0
],
[
2
,
3
,
4
])
except
debugmode
.
BadCLinkerOutput
,
e
:
print
repr
(
e
)
#
print repr(e)
assert
e
.
r
.
owner
.
op
is
inconsistent
return
# TEST PASS
...
...
@@ -490,7 +490,7 @@ class Test_ViewMap(unittest.TestCase):
f
([
1
,
2
,
3
,
4
],
[
5
,
6
,
7
,
8
])
assert
False
# DebugMode should have caught the error
except
debugmode
.
BadViewMap
,
e
:
print
e
#
print e
pass
# the situation can be rescued by picking one of the inputs and
...
...
@@ -554,7 +554,7 @@ class Test_check_isfinite(unittest.TestCase):
#inf should go through
infs
=
numpy
.
asarray
([
1.0
,
1.
,
1.
])
/
0
print
infs
#
print infs
f
(
infs
)
return
...
...
@@ -576,11 +576,11 @@ class BrokenCImplementationAdd(gof.Op):
return
r
def
perform
(
self
,
node
,
inp
,
out_
):
print
'executing python perform'
#
print 'executing python perform'
a
,
b
=
inp
out
,
=
out_
z
=
a
+
b
print
'out[0] was:'
,
out
[
0
]
#
print 'out[0] was:', out[0]
out
[
0
]
=
z
def
c_code_cache_version
(
self
):
...
...
theano/compile/tests/test_misc.py
浏览文件 @
0156327d
...
...
@@ -18,7 +18,7 @@ class NNet(object):
self
.
lr
=
shared
(
lr
,
'learning_rate'
)
self
.
w1
=
shared
(
numpy
.
zeros
((
n_hidden
,
n_input
)),
'w1'
)
self
.
w2
=
shared
(
numpy
.
zeros
((
n_output
,
n_hidden
)),
'w2'
)
print
self
.
lr
.
type
#
print self.lr.type
self
.
hidden
=
sigmoid
(
tensor
.
dot
(
self
.
w1
,
self
.
input
))
self
.
output
=
tensor
.
dot
(
self
.
w2
,
self
.
hidden
)
...
...
@@ -51,7 +51,7 @@ class TestNnet(unittest.TestCase):
output
,
cost
=
nnet
.
sgd_step
(
input
,
target
)
mean_cost
+=
cost
mean_cost
/=
float
(
len
(
data
))
print
'Mean cost at epoch
%
s:
%
s'
%
(
epoch
,
mean_cost
)
#
print 'Mean cost at epoch %s: %s' % (epoch, mean_cost)
self
.
assertTrue
(
abs
(
mean_cost
-
0.20588975452
)
<
1e-6
)
# Just call functions to make sure they do not crash.
out
=
nnet
.
compute_output
(
input
)
...
...
theano/compile/tests/test_module.py
浏览文件 @
0156327d
...
...
@@ -146,7 +146,7 @@ class T_module(unittest.TestCase):
#assign 4 and 5 to the two variables' containers in m
m
.
l
=
[
4
,
5
]
print
'm.f'
,
m
.
f
()
m
.
f
()
assert
numpy
.
all
(
5
==
m
.
f
())
assert
numpy
.
all
(
4
==
m
.
g
())
...
...
@@ -189,9 +189,9 @@ class T_module(unittest.TestCase):
assert
5
==
m
.
f
()
assert
4
==
m
.
g
()
print
'dscalar test'
#
print 'dscalar test'
local_test
(
lambda
:
T
.
dscalar
(),
lambda
:
T
.
dscalar
())
print
'value test'
#
print 'value test'
local_test
(
lambda
:
T
.
value
(
1
),
lambda
:
T
.
value
(
2
))
...
...
@@ -494,9 +494,9 @@ class T_module(unittest.TestCase):
M
.
a
=
[
1
,
2
,
3
]
M
.
make
()
m
=
M
.
make
()
print
m
.
a
print
m
.
a
[
0
],
type
(
m
.
a
[
0
]),
m
.
a
[
0
]
==
1
print
list
(
m
.
a
)
#
print m.a
#
print m.a[0], type(m.a[0]), m.a[0] == 1
#
print list(m.a)
assert
list
(
m
.
a
)
==
[
1
,
2
,
3
]
assert
m
.
a
is
not
M
.
a
try
:
...
...
@@ -545,7 +545,8 @@ def test_multiple_references():
self
.
sub_module
=
sub_module
def
_instance_initialize
(
self
,
obj
):
print
'Initializing A'
pass
#print 'Initializing A'
class
B
(
theano
.
Module
):
...
...
@@ -555,7 +556,8 @@ def test_multiple_references():
self
.
sub_module
=
sub_module
def
_instance_initialize
(
self
,
obj
):
print
'Initializing B'
pass
#print 'Initializing B'
class
C
(
theano
.
Module
):
...
...
@@ -565,11 +567,11 @@ def test_multiple_references():
self
.
value
=
theano
.
tensor
.
scalar
()
def
_instance_initialize
(
self
,
obj
):
print
'Initializing C'
#
print 'Initializing C'
obj
.
value
=
0
def
_instance_set
(
self
,
obj
,
value
):
print
'Setting C'
#
print 'Setting C'
obj
.
value
=
value
...
...
@@ -584,7 +586,7 @@ def test_multiple_references():
self
.
bug
=
theano
.
tensor
.
scalar
()
def
_instance_initialize
(
self
,
obj
):
print
'Initializing D'
#
print 'Initializing D'
obj
.
c
.
set
(
1
)
...
...
theano/compile/tests/test_pfunc.py
浏览文件 @
0156327d
...
...
@@ -369,7 +369,6 @@ class Test_pfunc(unittest.TestCase):
z
:
(((
x
*
5
)
+
y
)
**
z
)})
up
()
print
x
.
get_value
(
borrow
=
True
)
assert
numpy
.
all
(
x
.
get_value
()
==
20
)
assert
numpy
.
all
(
y
.
get_value
()
==
24
)
assert
numpy
.
all
(
z
.
get_value
()
==
(
24
**
2
))
...
...
@@ -380,7 +379,6 @@ class Test_pfunc(unittest.TestCase):
f
=
pfunc
([],
[
x
])
f
()
print
x
.
get_value
()
assert
x
.
get_value
()
==
1
del
x
.
default_update
...
...
@@ -399,32 +397,26 @@ class Test_pfunc(unittest.TestCase):
# Test that the default update is taken into account in the right cases
f1
=
pfunc
([],
[
x
],
no_default_updates
=
True
)
f1
()
print
x
.
get_value
()
assert
x
.
get_value
()
==
0
f2
=
pfunc
([],
[
x
],
no_default_updates
=
[
x
])
f2
()
print
x
.
get_value
()
assert
x
.
get_value
()
==
0
f3
=
pfunc
([],
[
x
],
no_default_updates
=
[
x
,
y
])
f3
()
print
x
.
get_value
()
assert
x
.
get_value
()
==
0
f4
=
pfunc
([],
[
x
],
no_default_updates
=
[
y
])
f4
()
print
x
.
get_value
()
assert
x
.
get_value
()
==
2
f5
=
pfunc
([],
[
x
],
no_default_updates
=
[])
f5
()
print
x
.
get_value
()
assert
x
.
get_value
()
==
4
f5
=
pfunc
([],
[
x
],
no_default_updates
=
False
)
f5
()
print
x
.
get_value
()
assert
x
.
get_value
()
==
6
self
.
assertRaises
(
TypeError
,
pfunc
,
[],
[
x
],
no_default_updates
=
(
x
))
...
...
@@ -435,32 +427,26 @@ class Test_pfunc(unittest.TestCase):
# Mix explicit updates and no_default_updates
g1
=
pfunc
([],
[
x
],
updates
=
[(
x
,
(
x
-
1
))],
no_default_updates
=
True
)
g1
()
print
x
.
get_value
()
assert
x
.
get_value
()
==
5
g2
=
pfunc
([],
[
x
],
updates
=
[(
x
,
(
x
-
1
))],
no_default_updates
=
[
x
])
g2
()
print
x
.
get_value
()
assert
x
.
get_value
()
==
4
g3
=
pfunc
([],
[
x
],
updates
=
[(
x
,
(
x
-
1
))],
no_default_updates
=
[
x
,
y
])
g3
()
print
x
.
get_value
()
assert
x
.
get_value
()
==
3
g4
=
pfunc
([],
[
x
],
updates
=
[(
x
,
(
x
-
1
))],
no_default_updates
=
[
y
])
g4
()
print
x
.
get_value
()
assert
x
.
get_value
()
==
2
g5
=
pfunc
([],
[
x
],
updates
=
[(
x
,
(
x
-
1
))],
no_default_updates
=
[])
g5
()
print
x
.
get_value
()
assert
x
.
get_value
()
==
1
g5
=
pfunc
([],
[
x
],
updates
=
[(
x
,
(
x
-
1
))],
no_default_updates
=
False
)
g5
()
print
x
.
get_value
()
assert
x
.
get_value
()
==
0
def
test_default_updates_expressions
(
self
):
...
...
@@ -473,17 +459,14 @@ class Test_pfunc(unittest.TestCase):
f1
=
pfunc
([
a
],
z
)
f1
(
12
)
print
x
assert
x
.
get_value
()
==
1
f2
=
pfunc
([
a
],
z
,
no_default_updates
=
True
)
assert
f2
(
7
)
==
7
print
x
assert
x
.
get_value
()
==
1
f3
=
pfunc
([
a
],
z
,
no_default_updates
=
[
x
])
assert
f3
(
9
)
==
9
print
x
assert
x
.
get_value
()
==
1
def
test_default_updates_multiple
(
self
):
...
...
@@ -524,7 +507,6 @@ class Test_pfunc(unittest.TestCase):
f1
=
pfunc
([],
[
x
])
f1
()
print
x
.
get_value
(),
y
.
get_value
(),
z
.
get_value
()
assert
x
.
get_value
()
==
1
assert
y
.
get_value
()
==
-
1
assert
z
.
get_value
()
==
-
2
...
...
@@ -598,10 +580,8 @@ class Test_pfunc(unittest.TestCase):
b
=
2
*
a
# Use only the tip of the graph, a is not used
f
=
pfunc
([
b
],
b
)
print
'a.get_value() ='
,
a
.
get_value
()
assert
a
.
get_value
()
==
0
f
(
21
)
print
'a.get_value() ='
,
a
.
get_value
()
assert
a
.
get_value
()
==
0
def
test_givens_replaces_shared_variable
(
self
):
...
...
@@ -917,7 +897,7 @@ class Test_aliasing_rules(unittest.TestCase):
data_of_b
=
data_of
(
B
)
f
=
pfunc
([],
[],
updates
=
[(
A
,
B
[:,
::
-
1
]),
(
B
,
A
.
T
)])
theano
.
printing
.
debugprint
(
f
)
#
theano.printing.debugprint(f)
f
()
# correctness (doesn't actually test the view...)
assert
numpy
.
all
(
data_of
(
A
)
==
-.
5
)
...
...
@@ -938,7 +918,6 @@ class Test_aliasing_rules(unittest.TestCase):
assert
numpy
.
all
(
data_of
(
B
)
<
5
)
data_of_a
+=
10
print
data_of
(
B
)
assert
numpy
.
all
(
data_of
(
B
)
>
5
)
data_of_a
-=
10
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论