提交 3127e645 authored 作者: Frederic's avatar Frederic

pep8

上级 8dabd398
...@@ -17,7 +17,7 @@ from theano.sparse import enable_sparse ...@@ -17,7 +17,7 @@ from theano.sparse import enable_sparse
from theano.gof.python25 import all, any, product from theano.gof.python25 import all, any, product
if enable_sparse == False: if not enable_sparse:
raise SkipTest('Optional package sparse disabled') raise SkipTest('Optional package sparse disabled')
from theano.sparse.basic import _is_dense, _is_sparse, _mtypes from theano.sparse.basic import _is_dense, _is_sparse, _mtypes
...@@ -35,7 +35,7 @@ from theano.sparse import ( ...@@ -35,7 +35,7 @@ from theano.sparse import (
SparseFromDense, SparseFromDense,
Cast, cast, HStack, VStack, AddSSData, add_s_s_data, Cast, cast, HStack, VStack, AddSSData, add_s_s_data,
structured_minimum, structured_maximum, structured_add, structured_minimum, structured_maximum, structured_add,
mul_s_v, structured_add_s_v, mul_s_v, structured_add_s_v,
SamplingDot, sampling_dot, SamplingDot, sampling_dot,
Diag, diag, SquareDiagonal, square_diagonal, Diag, diag, SquareDiagonal, square_diagonal,
EnsureSortedIndices, ensure_sorted_indices, clean, EnsureSortedIndices, ensure_sorted_indices, clean,
...@@ -372,17 +372,17 @@ class SparseInferShapeTester(utt.InferShapeTester): ...@@ -372,17 +372,17 @@ class SparseInferShapeTester(utt.InferShapeTester):
[x, y], [x, y],
[grads[0]], [grads[0]],
[as_sparse_format(random_lil((4, 5), [as_sparse_format(random_lil((4, 5),
config.floatX, 3), format), config.floatX, 3), format),
as_sparse_format(random_lil((5, 3), as_sparse_format(random_lil((5, 3),
config.floatX, 3), format)], config.floatX, 3), format)],
op) op)
self._compile_and_check( self._compile_and_check(
[x, y], [x, y],
[grads[1]], [grads[1]],
[as_sparse_format(random_lil((4, 5), [as_sparse_format(random_lil((4, 5),
config.floatX, 3), format), config.floatX, 3), format),
as_sparse_format(random_lil((5, 3), as_sparse_format(random_lil((5, 3),
config.floatX, 3), format)], config.floatX, 3), format)],
op) op)
def test_dense_from_sparse(self): def test_dense_from_sparse(self):
...@@ -398,8 +398,7 @@ class SparseInferShapeTester(utt.InferShapeTester): ...@@ -398,8 +398,7 @@ class SparseInferShapeTester(utt.InferShapeTester):
self._compile_and_check([x], self._compile_and_check([x],
[csc_from_dense(x)], [csc_from_dense(x)],
[numpy.random.randn(10, 40).astype( [numpy.random.randn(10, 40).astype(
config.floatX)], config.floatX)],
csc_from_dense.__class__) csc_from_dense.__class__)
def test_sparse_from_list(self): def test_sparse_from_list(self):
...@@ -674,27 +673,27 @@ class test_csm_properties(unittest.TestCase): ...@@ -674,27 +673,27 @@ class test_csm_properties(unittest.TestCase):
def test_csm_properties_grad(self): def test_csm_properties_grad(self):
sp_types = {'csc': sp.csc_matrix, sp_types = {'csc': sp.csc_matrix,
'csr': sp.csr_matrix} 'csr': sp.csr_matrix}
for format in ['csc', 'csr']: for format in ['csc', 'csr']:
for dtype in ['float32', 'float64']: for dtype in ['float32', 'float64']:
spmat = sp_types[format](random_lil((4, 3), dtype, 3)) spmat = sp_types[format](random_lil((4, 3), dtype, 3))
verify_grad_sparse(lambda *x: CSMProperties()(*x)[0], [spmat], verify_grad_sparse(lambda *x: CSMProperties()(*x)[0], [spmat],
structured=True) structured=True)
verify_grad_sparse(lambda *x: CSMProperties()(*x)[1], [spmat], verify_grad_sparse(lambda *x: CSMProperties()(*x)[1], [spmat],
structured=True) structured=True)
verify_grad_sparse(lambda *x: CSMProperties()(*x)[2], [spmat], verify_grad_sparse(lambda *x: CSMProperties()(*x)[2], [spmat],
structured=True) structured=True)
verify_grad_sparse(lambda *x: CSMProperties()(*x)[2], [spmat], verify_grad_sparse(lambda *x: CSMProperties()(*x)[2], [spmat],
structured=True) structured=True)
def test_csm_properties(self): def test_csm_properties(self):
sp_types = {'csc': sp.csc_matrix, sp_types = {'csc': sp.csc_matrix,
'csr': sp.csr_matrix} 'csr': sp.csr_matrix}
for format in ['csc', 'csr']: for format in ['csc', 'csr']:
for dtype in ['float32', 'float64']: for dtype in ['float32', 'float64']:
...@@ -717,7 +716,7 @@ class test_csm(unittest.TestCase): ...@@ -717,7 +716,7 @@ class test_csm(unittest.TestCase):
def test_csm_grad(self): def test_csm_grad(self):
sp_types = {'csc': sp.csc_matrix, sp_types = {'csc': sp.csc_matrix,
'csr': sp.csr_matrix} 'csr': sp.csr_matrix}
for format in ['csc', 'csr']: for format in ['csc', 'csr']:
for dtype in ['float32', 'float64']: for dtype in ['float32', 'float64']:
...@@ -732,7 +731,7 @@ class test_csm(unittest.TestCase): ...@@ -732,7 +731,7 @@ class test_csm(unittest.TestCase):
Test support for gradients sparser than the input. Test support for gradients sparser than the input.
""" """
sp_types = {'csc': sp.csc_matrix, sp_types = {'csc': sp.csc_matrix,
'csr': sp.csr_matrix} 'csr': sp.csr_matrix}
for format in ['csc', 'csr']: for format in ['csc', 'csr']:
for dtype in ['float32', 'float64']: for dtype in ['float32', 'float64']:
...@@ -742,7 +741,7 @@ class test_csm(unittest.TestCase): ...@@ -742,7 +741,7 @@ class test_csm(unittest.TestCase):
s = tensor.ivector() s = tensor.ivector()
a = as_sparse_variable(sp_types[format](random_lil((4, 3), a = as_sparse_variable(sp_types[format](random_lil((4, 3),
dtype, 1))) dtype, 1)))
f = theano.function([x, y, z, s], f = theano.function([x, y, z, s],
tensor.grad(dense_from_sparse( tensor.grad(dense_from_sparse(
...@@ -751,7 +750,7 @@ class test_csm(unittest.TestCase): ...@@ -751,7 +750,7 @@ class test_csm(unittest.TestCase):
spmat = sp_types[format](random_lil((4, 3), dtype, 3)) spmat = sp_types[format](random_lil((4, 3), dtype, 3))
res = f(spmat.data, spmat.indices, spmat.indptr, res = f(spmat.data, spmat.indices, spmat.indptr,
numpy.asarray(spmat.shape, 'int32')) numpy.asarray(spmat.shape, 'int32'))
assert len(spmat.data) == len(res) assert len(spmat.data) == len(res)
...@@ -760,7 +759,7 @@ class test_csm(unittest.TestCase): ...@@ -760,7 +759,7 @@ class test_csm(unittest.TestCase):
Test support for gradients of unsorted inputs. Test support for gradients of unsorted inputs.
""" """
sp_types = {'csc': sp.csc_matrix, sp_types = {'csc': sp.csc_matrix,
'csr': sp.csr_matrix} 'csr': sp.csr_matrix}
for format in ['csr', 'csc', ]: for format in ['csr', 'csc', ]:
for dtype in ['float32', 'float64']: for dtype in ['float32', 'float64']:
...@@ -773,7 +772,7 @@ class test_csm(unittest.TestCase): ...@@ -773,7 +772,7 @@ class test_csm(unittest.TestCase):
[1, 2, 1], [1, 2, 1],
[1, 2, 1], [1, 2, 1],
[1, 2, 1]], [1, 2, 1]],
dtype=dtype)[range(4)] dtype=dtype)[range(4)]
# Make sure it's unsorted # Make sure it's unsorted
assert not a.has_sorted_indices assert not a.has_sorted_indices
a = as_sparse_variable(a) a = as_sparse_variable(a)
...@@ -782,14 +781,15 @@ class test_csm(unittest.TestCase): ...@@ -782,14 +781,15 @@ class test_csm(unittest.TestCase):
dense_from_sparse(a * CSM(format)(x, y, z, s))), x)) dense_from_sparse(a * CSM(format)(x, y, z, s))), x))
spmat = sp_types[format](random_lil((4, 3), dtype, spmat = sp_types[format](random_lil((4, 3), dtype,
12))[range(4)] 12))[range(4)]
assert not spmat.has_sorted_indices assert not spmat.has_sorted_indices
res = f(spmat.data, spmat.indices, spmat.indptr, res = f(spmat.data, spmat.indices, spmat.indptr,
numpy.asarray(spmat.shape, 'int32')) numpy.asarray(spmat.shape, 'int32'))
col1 = sp_types[format]((res, spmat.indices, spmat.indptr), col1 = sp_types[format]((res, spmat.indices, spmat.indptr),
shape=numpy.asarray(spmat.shape, 'int32'))[:, 1].data shape=numpy.asarray(spmat.shape,
'int32'))[:, 1].data
assert numpy.all(col1 == 2) assert numpy.all(col1 == 2)
...@@ -808,7 +808,7 @@ class test_csm(unittest.TestCase): ...@@ -808,7 +808,7 @@ class test_csm(unittest.TestCase):
spmat = sp_types[format](random_lil((4, 3), dtype, 3)) spmat = sp_types[format](random_lil((4, 3), dtype, 3))
res = f(spmat.data, spmat.indices, spmat.indptr, res = f(spmat.data, spmat.indices, spmat.indptr,
numpy.asarray(spmat.shape, 'int32')) numpy.asarray(spmat.shape, 'int32'))
assert numpy.all(res.data == spmat.data) assert numpy.all(res.data == spmat.data)
assert numpy.all(res.indices == spmat.indices) assert numpy.all(res.indices == spmat.indices)
...@@ -909,8 +909,7 @@ class test_structureddot(unittest.TestCase): ...@@ -909,8 +909,7 @@ class test_structureddot(unittest.TestCase):
spmat = sp.csc_matrix(spmat) spmat = sp.csc_matrix(spmat)
images = tensor.Tensor(dtype='float32', images = tensor.Tensor(dtype='float32',
broadcastable=[False, False])( broadcastable=[False, False])('images')
'images')
cscmat = CSC(kerns, spmat.indices[:spmat.size], cscmat = CSC(kerns, spmat.indices[:spmat.size],
spmat.indptr, spmat.shape) spmat.indptr, spmat.shape)
...@@ -931,7 +930,8 @@ class test_structureddot(unittest.TestCase): ...@@ -931,7 +930,8 @@ class test_structureddot(unittest.TestCase):
#print 'type of kernvals = ', kernvals.dtype #print 'type of kernvals = ', kernvals.dtype
bsize = 3 bsize = 3
imvals = 1.0 * numpy.array(numpy.arange(bsize * spmat.shape[1]).\ imvals = 1.0 * numpy.array(numpy.arange(bsize * spmat.shape[1]).\
reshape(bsize, spmat.shape[1]), dtype='float32') reshape(bsize, spmat.shape[1]),
dtype='float32')
outvals = f(kernvals, imvals) outvals = f(kernvals, imvals)
#print outvals #print outvals
...@@ -949,10 +949,10 @@ class test_structureddot(unittest.TestCase): ...@@ -949,10 +949,10 @@ class test_structureddot(unittest.TestCase):
f = theano.function([a, b], theano.Out(d, borrow=True)) f = theano.function([a, b], theano.Out(d, borrow=True))
topo = f.maker.fgraph.toposort() topo = f.maker.fgraph.toposort()
for M, N, K, nnz in [(4, 3, 2, 3), for M, N, K, nnz in [(4, 3, 2, 3),
(40, 30, 20, 3), (40, 30, 20, 3),
(40, 30, 20, 30), (40, 30, 20, 30),
(400, 3000, 200, 6000), (400, 3000, 200, 6000),
]: ]:
a_val = sp_mat[sparse_format_a]( a_val = sp_mat[sparse_format_a](
random_lil((M, N), sparse_dtype, nnz)) random_lil((M, N), sparse_dtype, nnz))
b_val = sp_mat[sparse_format_b]( b_val = sp_mat[sparse_format_b](
...@@ -969,10 +969,10 @@ class test_structureddot(unittest.TestCase): ...@@ -969,10 +969,10 @@ class test_structureddot(unittest.TestCase):
f = theano.function([a, b], theano.Out(d, borrow=True)) f = theano.function([a, b], theano.Out(d, borrow=True))
for M, N, K, nnz in [(4, 3, 2, 3), for M, N, K, nnz in [(4, 3, 2, 3),
(40, 30, 20, 3), (40, 30, 20, 3),
(40, 30, 20, 30), (40, 30, 20, 30),
(400, 3000, 200, 6000), (400, 3000, 200, 6000),
]: ]:
spmat = sp.csc_matrix(random_lil((M, N), sparse_dtype, nnz)) spmat = sp.csc_matrix(random_lil((M, N), sparse_dtype, nnz))
mat = numpy.asarray(numpy.random.randn(N, K), dense_dtype) mat = numpy.asarray(numpy.random.randn(N, K), dense_dtype)
theano_times = [] theano_times = []
...@@ -1017,10 +1017,10 @@ class test_structureddot(unittest.TestCase): ...@@ -1017,10 +1017,10 @@ class test_structureddot(unittest.TestCase):
f = theano.function([a, b], d) f = theano.function([a, b], d)
for M, N, K, nnz in [(4, 3, 2, 3), for M, N, K, nnz in [(4, 3, 2, 3),
(40, 30, 20, 3), (40, 30, 20, 3),
(40, 30, 20, 30), (40, 30, 20, 30),
(400, 3000, 200, 6000), (400, 3000, 200, 6000),
]: ]:
spmat = sp.csr_matrix(random_lil((M, N), sparse_dtype, nnz)) spmat = sp.csr_matrix(random_lil((M, N), sparse_dtype, nnz))
mat = numpy.asarray(numpy.random.randn(N, K), dense_dtype) mat = numpy.asarray(numpy.random.randn(N, K), dense_dtype)
t0 = time.time() t0 = time.time()
...@@ -1062,7 +1062,7 @@ class DotTests(utt.InferShapeTester): ...@@ -1062,7 +1062,7 @@ class DotTests(utt.InferShapeTester):
self.v_10 = numpy.asarray(numpy.random.uniform(-1, 1, 10), self.v_10 = numpy.asarray(numpy.random.uniform(-1, 1, 10),
dtype=theano.config.floatX) dtype=theano.config.floatX)
self.v_100 = numpy.asarray(numpy.random.uniform(-1, 1, 100), self.v_100 = numpy.asarray(numpy.random.uniform(-1, 1, 100),
dtype=theano.config.floatX) dtype=theano.config.floatX)
def test_csr_dense(self): def test_csr_dense(self):
x = theano.sparse.csr_matrix('x') x = theano.sparse.csr_matrix('x')
...@@ -1143,7 +1143,7 @@ class DotTests(utt.InferShapeTester): ...@@ -1143,7 +1143,7 @@ class DotTests(utt.InferShapeTester):
a = sparse.csr_matrix('a', dtype='float32') a = sparse.csr_matrix('a', dtype='float32')
b = cuda.float32_shared_constructor( b = cuda.float32_shared_constructor(
numpy.random.rand(3, 4).astype('float32')) numpy.random.rand(3, 4).astype('float32'))
d = sparse.dot(a, b) d = sparse.dot(a, b)
f = theano.function([a], d) f = theano.function([a], d)
...@@ -1281,7 +1281,7 @@ class UsmmTests(unittest.TestCase): ...@@ -1281,7 +1281,7 @@ class UsmmTests(unittest.TestCase):
for node in topo]) == len(topo) - 5) for node in topo]) == len(topo) - 5)
new_topo = [] new_topo = []
for node in topo: for node in topo:
if not (isinstance(node.op, tensor.Elemwise) and \ if not (isinstance(node.op, tensor.Elemwise) and
isinstance(node.op.scalar_op, isinstance(node.op.scalar_op,
theano.scalar.basic.Cast)): theano.scalar.basic.Cast)):
new_topo.append(node) new_topo.append(node)
...@@ -1360,8 +1360,8 @@ class test_zeros_like(unittest.TestCase): ...@@ -1360,8 +1360,8 @@ class test_zeros_like(unittest.TestCase):
x = theano.sparse.csr_matrix() x = theano.sparse.csr_matrix()
f = theano.function([x], theano.sparse.sp_zeros_like(x)) f = theano.function([x], theano.sparse.sp_zeros_like(x))
vx = scipy.sparse.csr_matrix(numpy.asarray( vx = scipy.sparse.csr_matrix(numpy.asarray(
numpy.random.binomial(1, 0.5, (100, 100)), numpy.random.binomial(1, 0.5, (100, 100)),
dtype=theano.config.floatX)) dtype=theano.config.floatX))
fx = f(vx) fx = f(vx)
...@@ -1571,7 +1571,7 @@ class SpSumTester(utt.InferShapeTester): ...@@ -1571,7 +1571,7 @@ class SpSumTester(utt.InferShapeTester):
shape=(10, 10)) shape=(10, 10))
z = theano.sparse.sp_sum(variable[0], axis=axis) z = theano.sparse.sp_sum(variable[0], axis=axis)
if axis == None: if axis is None:
assert z.type.broadcastable == () assert z.type.broadcastable == ()
else: else:
assert z.type.broadcastable == (False, ) assert z.type.broadcastable == (False, )
...@@ -1951,24 +1951,26 @@ class Test_getitem(unittest.TestCase): ...@@ -1951,24 +1951,26 @@ class Test_getitem(unittest.TestCase):
# the [] shortcut for getitem. # the [] shortcut for getitem.
# x[a:b] is not accepted because we don't have sparse vectors # x[a:b] is not accepted because we don't have sparse vectors
self.assertRaises(NotImplementedError, self.assertRaises(NotImplementedError,
x.__getitem__, (slice(a, b), c)) x.__getitem__, (slice(a, b), c))
# x[a:b:step, c:d] is not accepted because scipy silently drops # x[a:b:step, c:d] is not accepted because scipy silently drops
# the step (!) # the step (!)
self.assertRaises(ValueError, self.assertRaises(ValueError,
x.__getitem__, (slice(a, b, -1), slice(c, d))) x.__getitem__, (slice(a, b, -1), slice(c, d)))
self.assertRaises(ValueError, self.assertRaises(ValueError,
x.__getitem__, (slice(a, b), slice(c, d, 2))) x.__getitem__, (slice(a, b), slice(c, d, 2)))
# Advanced indexing is not supported # Advanced indexing is not supported
self.assertRaises(ValueError, self.assertRaises(ValueError,
x.__getitem__, (tensor.ivector('l'), slice(a, b))) x.__getitem__,
(tensor.ivector('l'), slice(a, b)))
# Indexing with random things is not supported either # Indexing with random things is not supported either
self.assertRaises(ValueError, self.assertRaises(ValueError,
x.__getitem__, slice(tensor.fscalar('f'), None)) x.__getitem__, slice(tensor.fscalar('f'), None))
self.assertRaises(ValueError, self.assertRaises(ValueError,
x.__getitem__, (slice(None), slice([1, 3, 4], None))) x.__getitem__,
(slice(None), slice([1, 3, 4], None)))
def test_GetItemScalar(self): def test_GetItemScalar(self):
sparse_formats = ('csc', 'csr') sparse_formats = ('csc', 'csr')
...@@ -1981,7 +1983,7 @@ class Test_getitem(unittest.TestCase): ...@@ -1981,7 +1983,7 @@ class Test_getitem(unittest.TestCase):
n = 42 n = 42
vx = as_sparse_format(self.rng.binomial(1, 0.5, (97, 100)), vx = as_sparse_format(self.rng.binomial(1, 0.5, (97, 100)),
format).astype(theano.config.floatX) format).astype(theano.config.floatX)
f1 = theano.function([x, a, b], x[a, b]) f1 = theano.function([x, a, b], x[a, b])
r1 = f1(vx, 10, 10) r1 = f1(vx, 10, 10)
...@@ -2503,7 +2505,7 @@ FloorTester = elemwise_checker( ...@@ -2503,7 +2505,7 @@ FloorTester = elemwise_checker(
numpy.floor, numpy.floor,
grad_test=False, grad_test=False,
test_dtypes=[m for m in sparse.all_dtypes test_dtypes=[m for m in sparse.all_dtypes
if not m in sparse.complex_dtypes]) if not m in sparse.complex_dtypes])
Log1pTester = elemwise_checker( Log1pTester = elemwise_checker(
sparse.log1p, sparse.log1p,
...@@ -2518,20 +2520,20 @@ Deg2radTester = elemwise_checker( ...@@ -2518,20 +2520,20 @@ Deg2radTester = elemwise_checker(
sparse.deg2rad, sparse.deg2rad,
numpy.deg2rad, numpy.deg2rad,
test_dtypes=[m for m in sparse.all_dtypes test_dtypes=[m for m in sparse.all_dtypes
if not m in sparse.complex_dtypes]) if not m in sparse.complex_dtypes])
Rad2degTester = elemwise_checker( Rad2degTester = elemwise_checker(
sparse.rad2deg, sparse.rad2deg,
numpy.rad2deg, numpy.rad2deg,
test_dtypes=[m for m in sparse.all_dtypes test_dtypes=[m for m in sparse.all_dtypes
if not m in sparse.complex_dtypes]) if not m in sparse.complex_dtypes])
TruncTester = elemwise_checker( TruncTester = elemwise_checker(
sparse.trunc, sparse.trunc,
numpy.trunc, numpy.trunc,
test_dtypes=[m for m in sparse.all_dtypes test_dtypes=[m for m in sparse.all_dtypes
if not m in sparse.complex_dtypes]) if not m in sparse.complex_dtypes])
SqrTester = elemwise_checker( SqrTester = elemwise_checker(
...@@ -2550,7 +2552,7 @@ class MulSVTester(unittest.TestCase): ...@@ -2550,7 +2552,7 @@ class MulSVTester(unittest.TestCase):
def test_mul_s_v_grad(self): def test_mul_s_v_grad(self):
sp_types = {'csc': sp.csc_matrix, sp_types = {'csc': sp.csc_matrix,
'csr': sp.csr_matrix} 'csr': sp.csr_matrix}
for format in ['csr', 'csc']: for format in ['csr', 'csc']:
for dtype in ['float32', 'float64']: for dtype in ['float32', 'float64']:
...@@ -2558,7 +2560,8 @@ class MulSVTester(unittest.TestCase): ...@@ -2558,7 +2560,8 @@ class MulSVTester(unittest.TestCase):
mat = numpy.asarray(numpy.random.rand(3), dtype=dtype) mat = numpy.asarray(numpy.random.rand(3), dtype=dtype)
theano.sparse.verify_grad_sparse(mul_s_v, theano.sparse.verify_grad_sparse(mul_s_v,
[spmat, mat], structured=True) [spmat, mat],
structured=True)
def test_mul_s_v(self): def test_mul_s_v(self):
sp_types = {'csc': sp.csc_matrix, sp_types = {'csc': sp.csc_matrix,
...@@ -2592,7 +2595,8 @@ class StructuredAddSVTester(unittest.TestCase): ...@@ -2592,7 +2595,8 @@ class StructuredAddSVTester(unittest.TestCase):
mat = numpy.asarray(numpy.random.rand(3), dtype=dtype) mat = numpy.asarray(numpy.random.rand(3), dtype=dtype)
theano.sparse.verify_grad_sparse(structured_add_s_v, theano.sparse.verify_grad_sparse(structured_add_s_v,
[spmat, mat], structured=True) [spmat, mat],
structured=True)
def test_structured_add_s_v(self): def test_structured_add_s_v(self):
sp_types = {'csc': sp.csc_matrix, sp_types = {'csc': sp.csc_matrix,
...@@ -2620,11 +2624,11 @@ class SamplingDotTester(utt.InferShapeTester): ...@@ -2620,11 +2624,11 @@ class SamplingDotTester(utt.InferShapeTester):
x.append(sparse.csr_matrix()) x.append(sparse.csr_matrix())
#unsquare shape #unsquare shape
a = [numpy.array(numpy.random.random_integers(5, size=(4, 3)) - 1, a = [numpy.array(numpy.random.random_integers(5, size=(4, 3)) - 1,
dtype=theano.config.floatX), dtype=theano.config.floatX),
numpy.array(numpy.random.random_integers(5, size=(5, 3)) - 1, numpy.array(numpy.random.random_integers(5, size=(5, 3)) - 1,
dtype=theano.config.floatX), dtype=theano.config.floatX),
numpy.array(numpy.random.random_integers(2, size=(4, 5)) - 1, numpy.array(numpy.random.random_integers(2, size=(4, 5)) - 1,
dtype=theano.config.floatX) dtype=theano.config.floatX)
] ]
a[2] = sp.csr_matrix(a[2]) a[2] = sp.csr_matrix(a[2])
...@@ -2674,7 +2678,7 @@ test_shared_options = theano.tensor.tests.test_sharedvar.makeSharedTester( ...@@ -2674,7 +2678,7 @@ test_shared_options = theano.tensor.tests.test_sharedvar.makeSharedTester(
ref_fct_=lambda a: numpy.asarray((a * 2).todense()), ref_fct_=lambda a: numpy.asarray((a * 2).todense()),
cast_value_=scipy.sparse.csr_matrix, cast_value_=scipy.sparse.csr_matrix,
name='test_shared_options', name='test_shared_options',
) )
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论