def test_sparse(self): mySymbolicSparseList = TypedListType( sparse.SparseType('csr', theano.config.floatX))() mySymbolicSparse = sparse.csr_matrix() z = Index()(mySymbolicSparseList, mySymbolicSparse) f = theano.function([mySymbolicSparseList, mySymbolicSparse], z) x = sp.csr_matrix(random_lil((10, 40), theano.config.floatX, 3)) y = sp.csr_matrix(random_lil((10, 40), theano.config.floatX, 3)) self.assertTrue(f([x, y], y) == 1)
def test_sanity_check(self): mySymbolicMatricesList = TypedListType( T.TensorType(theano.config.floatX, (False, False)))() myMatrix = T.matrix() z = Index()(mySymbolicMatricesList, myMatrix) f = theano.function([mySymbolicMatricesList, myMatrix], z) x = rand_ranged_matrix(-1000, 1000, [100, 101]) y = rand_ranged_matrix(-1000, 1000, [100, 101]) self.assertTrue(f([x, y], y) == 1)
def test_sparse(self): sp = pytest.importorskip("scipy") mySymbolicSparseList = TypedListType( sparse.SparseType("csr", theano.config.floatX))() mySymbolicSparse = sparse.csr_matrix() z = Index()(mySymbolicSparseList, mySymbolicSparse) f = theano.function([mySymbolicSparseList, mySymbolicSparse], z) x = sp.sparse.csr_matrix(random_lil((10, 40), theano.config.floatX, 3)) y = sp.sparse.csr_matrix(random_lil((10, 40), theano.config.floatX, 3)) assert f([x, y], y) == 1
def test_sparse(self): if not scipy_imported: raise SkipTest('Optional package SciPy not installed') mySymbolicSparseList = TypedListType( sparse.SparseType('csr', theano.config.floatX))() mySymbolicSparse = sparse.csr_matrix() z = Index()(mySymbolicSparseList, mySymbolicSparse) f = theano.function([mySymbolicSparseList, mySymbolicSparse], z) x = sp.csr_matrix(random_lil((10, 40), theano.config.floatX, 3)) y = sp.csr_matrix(random_lil((10, 40), theano.config.floatX, 3)) self.assertTrue(f([x, y], y) == 1)
def test_non_tensor_type(self): mySymbolicNestedMatricesList = TypedListType( T.TensorType(theano.config.floatX, (False, False)), 1)() mySymbolicMatricesList = TypedListType( T.TensorType(theano.config.floatX, (False, False)))() z = Index()(mySymbolicNestedMatricesList, mySymbolicMatricesList) f = theano.function( [mySymbolicNestedMatricesList, mySymbolicMatricesList], z) x = rand_ranged_matrix(-1000, 1000, [100, 101]) y = rand_ranged_matrix(-1000, 1000, [100, 101]) self.assertTrue(f([[x, y], [x, y, y]], [x, y]) == 0)
def test_sparse(self): if not scipy_imported: pytest.skip("Optional package SciPy not installed") mySymbolicSparseList = TypedListType( sparse.SparseType("csr", theano.config.floatX) )() mySymbolicSparse = sparse.csr_matrix() z = Index()(mySymbolicSparseList, mySymbolicSparse) f = theano.function([mySymbolicSparseList, mySymbolicSparse], z) x = sp.csr_matrix(random_lil((10, 40), theano.config.floatX, 3)) y = sp.csr_matrix(random_lil((10, 40), theano.config.floatX, 3)) assert f([x, y], y) == 1