提交 9cbb58f4 authored 作者: Frederic Bastien's avatar Frederic Bastien

make tests less verbose

上级 68ec79f5
......@@ -750,10 +750,10 @@ def max_pool(images, imgshp, maxpoolshp):
convolution_indices.conv_eval(imgshp, maxpoolshp,
maxpoolshp, mode='valid')
print 'XXXXXXXXXXXXXXXX MAX POOLING LAYER XXXXXXXXXXXXXXXXXXXX'
print 'imgshp = ', imgshp
print 'maxpoolshp = ', maxpoolshp
print 'outshp = ', outshp
# print 'XXXXXXXXXXXXXXXX MAX POOLING LAYER XXXXXXXXXXXXXXXXXXXX'
# print 'imgshp = ', imgshp
# print 'maxpoolshp = ', maxpoolshp
# print 'outshp = ', outshp
# build sparse matrix, then generate stack of image patches
csc = theano.sparse.CSM(sptype)(N.ones(indices.size), indices,
......
......@@ -21,9 +21,9 @@ from theano.tests import unittest_tools as utt
class TestSP(unittest.TestCase):
def test_convolution(self):
print '\n\n*************************************************'
print ' TEST CONVOLUTION'
print '*************************************************'
# print '\n\n*************************************************'
# print ' TEST CONVOLUTION'
# print '*************************************************'
# fixed parameters
bsize = 10 # batch size
......@@ -118,18 +118,18 @@ class TestSP(unittest.TestCase):
#assert numpy.all(visref==visval)
print '**** Convolution Profiling Results (',mode,') ****'
print 'Numpy processing time: ', ntot
print 'Theano processing time: ', ttot
# print '**** Convolution Profiling Results (',mode,') ****'
# print 'Numpy processing time: ', ntot
# print 'Theano processing time: ', ttot
#profmode.print_summary()
def test_sparse(self):
print '\n\n*************************************************'
print ' TEST SPARSE'
print '*************************************************'
# print '\n\n*************************************************'
# print ' TEST SPARSE'
# print '*************************************************'
# fixed parameters
bsize = 10 # batch size
......@@ -209,9 +209,9 @@ class TestSP(unittest.TestCase):
visref = numpy.dot(out1,spmat.todense())
assert numpy.all(visref==visval), (visref, visval)
print '**** Sparse Profiling Results (',mode,') ****'
print 'Numpy processing time: ', ntot
print 'Theano processing time: ', ttot
# print '**** Sparse Profiling Results (',mode,') ****'
# print 'Numpy processing time: ', ntot
# print 'Theano processing time: ', ttot
#profmode.print_summary()
......@@ -409,7 +409,7 @@ class TestSP(unittest.TestCase):
# Sparse gradient on Sum on all axis
# unfinished, and suspended until verify_grad get fixed
if False:
print 'grad on sum on all axis...'
# print 'grad on sum on all axis...'
def fun(x):
## verify_grad does not handle sparse data, so here's some casting as a workaround.
# x is a dense matrix: make it sparse
......@@ -421,11 +421,11 @@ class TestSP(unittest.TestCase):
dense_sum = theano.sparse.DenseFromSparse()(sparse_sum)
return dense_sum
x_val = x_data.copy()
print type(x_val)
# print type(x_val)
import pdb;pdb.set_trace()
tensor.verify_grad(fun, [x_val], rng=rng)
#utt.verify_grad(SpSum(axis=None), [x_val])
print 'ok'
# print 'ok'
def test_diag():
......@@ -513,8 +513,8 @@ def test_row_scale():
f = theano.function([x, s], sp.row_scale(x, s))
print 'A', f(x_val, s_val).toarray()
print 'B', (x_val_dense.T * s_val).T
# print 'A', f(x_val, s_val).toarray()
# print 'B', (x_val_dense.T * s_val).T
assert numpy.all(f(x_val, s_val).toarray() == (x_val_dense.T * s_val).T)
......@@ -544,8 +544,8 @@ def test_col_scale():
f = theano.function([x, s], sp.col_scale(x, s))
print 'A', f(x_val, s_val).toarray()
print 'B', (x_val_dense * s_val)
# print 'A', f(x_val, s_val).toarray()
# print 'B', (x_val_dense * s_val)
assert numpy.all(f(x_val, s_val).toarray() == (x_val_dense * s_val))
......
......@@ -624,11 +624,11 @@ class test_structureddot(unittest.TestCase):
spmat.dtype = numpy.dtype(sparse_dtype)
mat = numpy.asarray(numpy.random.randn(N, K) * 9,
dtype=dense_dtype)
print 'DTYPES', sparse_dtype, dense_dtype
print 'sym types', a.type, b.type
print 'dtype strings', spmat.dtype, mat.dtype
print 'numpy dtype num', mat.dtype.num
print 'scipy dtype num', spmat.data.dtype.num
#print 'DTYPES', sparse_dtype, dense_dtype
#print 'sym types', a.type, b.type
#print 'dtype strings', spmat.dtype, mat.dtype
#print 'numpy dtype num', mat.dtype.num
#print 'scipy dtype num', spmat.data.dtype.num
theano_result = f(spmat, mat)
scipy_result = spmat * mat
assert theano_result.shape == scipy_result.shape
......@@ -665,7 +665,7 @@ class test_structureddot(unittest.TestCase):
sdcscpresent = False
for node in f.maker.env.toposort():
print node.op
#print node.op
assert not isinstance(node.op, CSM)
assert not isinstance(node.op, CSMProperties)
if isinstance(f.maker.env.toposort()[1].op, StructuredDotCSC):
......@@ -680,7 +680,7 @@ class test_structureddot(unittest.TestCase):
imvals = 1.0 * numpy.array(numpy.arange(bsize * spmat.shape[1]).\
reshape(bsize, spmat.shape[1]), dtype='float32')
outvals = f(kernvals, imvals)
print outvals
#print outvals
def test_dot_sparse_sparse(self):
#test dot for 2 input sparse matrix
......@@ -738,10 +738,10 @@ class test_structureddot(unittest.TestCase):
scipy_time = numpy.min(scipy_times)
speedup = scipy_time / theano_time
print scipy_times
print theano_times
print ('M=%(M)s N=%(N)s K=%(K)s nnz=%(nnz)s theano_time'
'=%(theano_time)s speedup=%(speedup)s') % locals()
#print scipy_times
#print theano_times
#print ('M=%(M)s N=%(N)s K=%(K)s nnz=%(nnz)s theano_time'
# '=%(theano_time)s speedup=%(speedup)s') % locals()
# fail if Theano is slower than scipy by more than a certain amount
overhead_tol = 0.003 # seconds overall
......@@ -778,10 +778,8 @@ class test_structureddot(unittest.TestCase):
theano_time = t1 - t0
scipy_time = t2 - t1
#print theano_result
#print scipy_result
print 'theano took', theano_time,
print 'scipy took', scipy_time
#print 'theano took', theano_time,
#print 'scipy took', scipy_time
overhead_tol = 0.002 # seconds
overhead_rtol = 1.1 # times as long
self.assertTrue(numpy.allclose(theano_result, scipy_result))
......@@ -1169,16 +1167,12 @@ def test_size():
def test_remove0():
print
print 'test_remove0()'
configs = [
# structure type, numpy matching class
('csc', scipy.sparse.csc_matrix),
('csr', scipy.sparse.csr_matrix),
]
for format, matrix_class in configs:
print ('config: format=\'%(format)s\','
' matrix_class=%(matrix_class)s' % locals())
# real
origin = (numpy.arange(9) + 1).reshape((3, 3)).astype(config.floatX)
mat = matrix_class(origin).astype(theano.config.floatX)
......
......@@ -164,7 +164,7 @@ class InferShapeTester(unittest.TestCase):
outputs_function = theano.function(inputs, outputs, mode=self.mode)
shapes_function = theano.function(inputs, [o.shape for o in outputs],
mode=self.mode)
theano.printing.debugprint(shapes_function)
#theano.printing.debugprint(shapes_function)
# Check that the Op is removed from the compiled function.
topo_shape = shapes_function.maker.env.toposort()
assert not any(isinstance(t.op, cls) for t in topo_shape)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论