The sparse module has been used in:
The sparse module is less mature than the tensor module. This documentation is also not mature.
The sparse submodule is not loaded when we import theano. You must import theano.sparse to enable it.
The sparse module provides two kinds of sparse tensors are supported: CSC matrices and CSR matrices. Operations that are implemented:
grad?
There are no GPU implementations for sparse matrices implemented in Theano.
Some documentation for sparse has been written here.
Platforms: Unix, Windows
Classes for handling sparse matrices.
To read about different sparse formats, see U{http://www-users.cs.umn.edu/~saad/software/SPARSKIT/paper.ps}.
@todo: Automatic methods for determining best sparse format?
Add a sparse and a dense matrix
Add two sparse matrices
Construct a CSC or CSR matrix from the internal representation
WRITEME
Return a gradient on the data vector
WRITEME
Build a SparseVariable from the internal parametrization
| Parameters: |
|
|---|
Build a csc_matrix
Extract all of .data .indices and .indptr
WRITEME
Convert a sparse matrix to an ndarray.
WRITEME
Operation for efficiently calculating the dot product when one or all operands is sparse. Supported format are CSC and CSR. The output of the operation is dense.
Implement a subtensor of sparse variable and that return a sparse matrix.
If you want to take only one element of a sparse matrix see the class GetItemScalar that return a tensor scalar.
| Note : | that subtensor selection always returns a matrix so |
|---|
indexing with [a:b, c:d] is forced. If one index is a scalar, e.g. x[a:b, c] and x[a, b:c], generate an error. Use instead x[a:b, c:c+1] and x[a:a+1, b:c].
The above indexing methods are not supported because the rval would be a sparse matrix rather than a sparse vector, which is a deviation from numpy indexing rule. This decision is made largely for keeping the consistency between numpy and theano. Subjected to modification when sparse vector is supported.
Implement a subtensor of a sparse variable that take two scalar as index and return a scalar
| See : | GetItem2d to return more then one element. |
|---|
Elementwise multiply a sparse and a ndarray
Elementwise multiply a sparse and a sparse
@type dtype: numpy dtype string such as ‘int64’ or ‘float64’ (among others) @type format: string @ivar format: The sparse storage strategy.
@note As far as I can tell, L{scipy.sparse} objects must be matrices, i.e. have dimension 2.
Structured Dot is like dot, except that only the gradient wrt non-zero elements of the sparse matrix A are calculated and propagated.
The output is presumed to be a dense matrix, and is represented by a TensorType instance.
Performs the expression is alpha * x y + z
x or y are sparse matrix(the other can be sparse or dense) z is a dense matrix alpha is a scalar
| Note : | We don’t implement the infer_shape as it is inserted by optimization only |
|---|
Performs the expression is alpha * x y + z This is an optimized operation for the case when x is in CSC format.
x are sparse matrix y, z is a dense matrix alpha is a scalar
| Note : | We don’t implement the infer_shape as it is inserted by optimization only |
|---|
Add two matrices, at least one of which is sparse.
Wrapper around SparseVariable constructor. @param x: A sparse matrix. as_sparse_variable reads dtype and format properties out of this sparse matrix. @return: SparseVariable version of sp.
@todo Verify that sp is sufficiently sparse, and raise a warning if it is not
If we can’t make a sparse variable, we try to make a tensor variable.
Wrapper around SparseVariable constructor. @param x: A sparse matrix. as_sparse_variable reads dtype and format properties out of this sparse matrix. @return: SparseVariable version of sp.
@todo Verify that sp is sufficiently sparse, and raise a warning if it is not
Operation for efficiently calculating the dot product when one or all operands is sparse. Supported format are CSC and CSR. The output of the operation is dense.
Multiply (elementwise) two matrices, at least one of which is sparse.
@todo: Maybe the triple-transposition formulation (when x is dense) is slow. See if there is a direct way to do this. (JB 20090528: Transposing tensors and sparse matrices is constant-time, inplace, and fast.)