提交 ce8cc0f8 authored 作者: Frederic's avatar Frederic

make tests less verbose.

上级 39cf88bd
...@@ -117,17 +117,17 @@ def test_ifelse(): ...@@ -117,17 +117,17 @@ def test_ifelse():
mode=Mode(linker=linker, optimizer='fast_run')) mode=Mode(linker=linker, optimizer='fast_run'))
try: try:
print "case 1" #print "case 1"
f(1, 'a', 'b') f(1, 'a', 'b')
assert False assert False
except NotImplementedOp.E: except NotImplementedOp.E:
pass pass
print "... passed" #print "... passed"
print "case 2" #print "case 2"
print f(0, 'a', 'b') #print f(0, 'a', 'b')
assert f(0, 'a', 'b') == 'b' assert f(0, 'a', 'b') == 'b'
print "... passed" #print "... passed"
def more_complex_test(): def more_complex_test():
......
...@@ -360,7 +360,7 @@ class TestEquilibrium(object): ...@@ -360,7 +360,7 @@ class TestEquilibrium(object):
x, y, z = map(MyVariable, 'xyz') x, y, z = map(MyVariable, 'xyz')
e = op3(op4(x, y)) e = op3(op4(x, y))
g = Env([x, y, z], [e]) g = Env([x, y, z], [e])
print g #print g
opt = EquilibriumOptimizer( opt = EquilibriumOptimizer(
[PatternSub((op1, 'x', 'y'), (op2, 'x', 'y')), [PatternSub((op1, 'x', 'y'), (op2, 'x', 'y')),
PatternSub((op4, 'x', 'y'), (op1, 'x', 'y')), PatternSub((op4, 'x', 'y'), (op1, 'x', 'y')),
...@@ -368,14 +368,14 @@ class TestEquilibrium(object): ...@@ -368,14 +368,14 @@ class TestEquilibrium(object):
], ],
max_use_ratio = 10) max_use_ratio = 10)
opt.optimize(g) opt.optimize(g)
print g #print g
assert str(g) == '[Op2(x, y)]' assert str(g) == '[Op2(x, y)]'
def test_2(self): def test_2(self):
x, y, z = map(MyVariable, 'xyz') x, y, z = map(MyVariable, 'xyz')
e = op1(op1(op3(x, y))) e = op1(op1(op3(x, y)))
g = Env([x, y, z], [e]) g = Env([x, y, z], [e])
print g #print g
opt = EquilibriumOptimizer( opt = EquilibriumOptimizer(
[PatternSub((op1, (op2, 'x', 'y')), (op4, 'x', 'y')), [PatternSub((op1, (op2, 'x', 'y')), (op4, 'x', 'y')),
PatternSub((op3, 'x', 'y'), (op4, 'x', 'y')), PatternSub((op3, 'x', 'y'), (op4, 'x', 'y')),
...@@ -391,7 +391,7 @@ class TestEquilibrium(object): ...@@ -391,7 +391,7 @@ class TestEquilibrium(object):
x, y, z = map(MyVariable, 'xyz') x, y, z = map(MyVariable, 'xyz')
e = op3(op4(x, y)) e = op3(op4(x, y))
g = Env([x, y, z], [e]) g = Env([x, y, z], [e])
print 'before', g #print 'before', g
# display pesky warnings along with stdout # display pesky warnings along with stdout
# also silence logger for 'theano.gof.opt' # also silence logger for 'theano.gof.opt'
_logger = logging.getLogger('theano.gof.opt') _logger = logging.getLogger('theano.gof.opt')
...@@ -407,5 +407,5 @@ class TestEquilibrium(object): ...@@ -407,5 +407,5 @@ class TestEquilibrium(object):
opt.optimize(g) opt.optimize(g)
finally: finally:
_logger.setLevel(oldlevel) _logger.setLevel(oldlevel)
print 'after', g #print 'after', g
assert str(g) == '[Op1(x, y)]' assert str(g) == '[Op1(x, y)]'
...@@ -726,7 +726,7 @@ class TestConv2DGPU(unittest.TestCase): ...@@ -726,7 +726,7 @@ class TestConv2DGPU(unittest.TestCase):
featshp_logical = (featshp[0], featshp[1], featshp[2] * stride, featshp_logical = (featshp[0], featshp[1], featshp[2] * stride,
featshp[3] * stride) featshp[3] * stride)
kshp_rotated = (kshp[1], kshp[0], kshp[2], kshp[3]) kshp_rotated = (kshp[1], kshp[0], kshp[2], kshp[3])
print featshp, kshp_rotated, featshp_logical[1:], kshp[2:] #print featshp, kshp_rotated, featshp_logical[1:], kshp[2:]
image_estimate = tensor.nnet.conv2d(a, kernel_rotated, image_estimate = tensor.nnet.conv2d(a, kernel_rotated,
border_mode='full', border_mode='full',
image_shape=featshp, image_shape=featshp,
...@@ -735,7 +735,7 @@ class TestConv2DGPU(unittest.TestCase): ...@@ -735,7 +735,7 @@ class TestConv2DGPU(unittest.TestCase):
kshp_logical=kshp[2:]) kshp_logical=kshp[2:])
func = theano.function([a, A], image_estimate, mode=theano_mode) func = theano.function([a, A], image_estimate, mode=theano_mode)
theano.printing.debugprint(func,) #theano.printing.debugprint(func,)
assert any([isinstance(node.op, theano.sandbox.cuda.blas.GpuConv) assert any([isinstance(node.op, theano.sandbox.cuda.blas.GpuConv)
for node in func.maker.fgraph.toposort()]) for node in func.maker.fgraph.toposort()])
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论