提交 2081af30 authored 作者: Nicolas Bouchard's avatar Nicolas Bouchard

Add grad to list and missing links.

上级 c6177e3a
...@@ -119,32 +119,48 @@ List of Implemented Operations ...@@ -119,32 +119,48 @@ List of Implemented Operations
============================== ==============================
- Moving from and to sparse - Moving from and to sparse
- :class:`DenseFromSparse <theano.sparse.basic.DenseFromSparse>` and ``dense_from_sparse`` - :class:`DenseFromSparse <theano.sparse.basic.DenseFromSparse>` and ``dense_from_sparse``.
- :class:`SparseFromDense <theano.sparse.basic.SparseFromDense>` and ``csr_from_dense``, ``csc_from_dense`` Both grad are implemented. Structured by default.
- :class:`SparseFromDense <theano.sparse.basic.SparseFromDense>` and ``csr_from_dense``, ``csc_from_dense``.
The grad implemented is structured.
- Construction of Sparses and their Properties - Construction of Sparses and their Properties
- :class:`CSM <theano.sparse.basic.CSM>` and ``CSC``, ``CSR`` to construct a matrix - :class:`CSM <theano.sparse.basic.CSM>` and ``CSC``, ``CSR`` to construct a matrix.
- :class:`CSMProperties <theano.sparse.basic.CSMProperties>` to get the properties of a sparse matrix The grad implemented is regular.
- ``sp_ones_like`` - :class:`CSMProperties <theano.sparse.basic.CSMProperties>` to get the properties of a sparse matrix.
- ``sp_zeros_like`` The grad implemented is regular.
- :class:`SquareDiagonal <theano.sparse.basic.SquareDiagonal>` and ``square_diagonal`` - :func:`sp_ones_like <theano.sparse.basic.sp_ones_like>`.
The grad implemented is regular.
- :func:`sp_zeros_like <theano.sparse.basic.sp_zeros_like>`.
The grad implemented is regular.
- :class:`SquareDiagonal <theano.sparse.basic.SquareDiagonal>` and ``square_diagonal``.
The grad implemented is regular.
- Cast - Cast
- :class:`Cast <theano.sparse.basic.Cast>` with ``bcast``, ``wcast``, ``icast``, ``lcast``, - :class:`Cast <theano.sparse.basic.Cast>` with ``bcast``, ``wcast``, ``icast``, ``lcast``,
``fcast``, ``dcast``, ``ccast``, and ``zcast`` ``fcast``, ``dcast``, ``ccast``, and ``zcast``.
The grad implemented is regular.
- Transpose - Transpose
- :class:`Transpose <theano.sparse.basic.Transpose>` and ``transpose`` - :class:`Transpose <theano.sparse.basic.Transpose>` and ``transpose``.
The grad implemented is regular.
- Basic Arithmetic - Basic Arithmetic
- :class:`Neg <theano.sparse.basic.Neg>` for negation - :class:`Neg <theano.sparse.basic.Neg>`.
- ``add`` for addition The grad implemented is regular.
- ``sub`` for substraction - :func:`add <theano.sparse.basic.add>`.
- ``mul`` for multiplication The grad implemented is regular.
- ``col_scale`` to multiply by a vector along the columns - :func:`sub <theano.sparse.basic.sub>`.
- ``row_slace`` to multiply by a vector along the rows The grad implemented is regular.
- :func:`mul <theano.sparse.basic.mul>`.
- Monoid (Element-wise operation with only one input) The grad implemented is regular.
- :func:`col_scale <theano.sparse.basic.col_scale>` to multiply by a vector along the columns.
The grad implemented is structured.
- :func:`row_slace <theano.sparse.basic.row_scale>` to multiply by a vector along the rows.
The grad implemented is structured.
- Monoid (Element-wise operation with only one sparse input).
`They all have a structured grad.`
- ``structured_sigmoid`` - ``structured_sigmoid``
- ``structured_exp`` - ``structured_exp``
- ``structured_log`` - ``structured_log``
...@@ -169,33 +185,45 @@ List of Implemented Operations ...@@ -169,33 +185,45 @@ List of Implemented Operations
- ``sqrt`` - ``sqrt``
- Dot Product - Dot Product
- :class:`Dot <theano.sparse.basic.Dot>` and ``dot`` - :class:`Dot <theano.sparse.basic.Dot>` and ``dot``.
- :class:`StructuredDot <theano.sparse.basic.StructuredDot>` and ``structured_dot`` The grad implemented is regular.
- :class:`SamplingDot <theano.sparse.basic.SamplingDot>` and ``sampling_dot`` - :class:`StructuredDot <theano.sparse.basic.StructuredDot>`
- :class:`Usmm <theano.sparse.basic.Usmm>` and ``usmm`` and :func:`structured_dot <theano.sparse.basic.structured_dot>`.
The grad implemented is structured.
- :class:`SamplingDot <theano.sparse.basic.SamplingDot>` and ``sampling_dot``.
The grad implemented is structured for `p`.
- :class:`Usmm <theano.sparse.basic.Usmm>` and ``usmm``.
There is no grad implemented for this op.
- Slice Operations - Slice Operations
- sparse_variable[N, N], return a tensor scalar - sparse_variable[N, N], return a tensor scalar.
There is no grad implemented for this operation.
- sparse_variable[M:N, O:P], return a sparse matrix - sparse_variable[M:N, O:P], return a sparse matrix
There is no grad implemented for this operation.
- Sparse variable don't support [M, N:O] and [M:N, O] as we don't support sparse vector - Sparse variable don't support [M, N:O] and [M:N, O] as we don't support sparse vector
and returning a sparse matrix would break the numpy interface. and returning a sparse matrix would break the numpy interface.
Use [M:M+1, N:O] and [M:N, O:O+1] instead. Use [M:M+1, N:O] and [M:N, O:O+1] instead.
- :class:`Diag <theano.sparse.basic.Diag>` and ``diag`` - :class:`Diag <theano.sparse.basic.Diag>` and ``diag``.
The grad implemented is regular.
- Concatenation - Concatenation
- :class:`HStack <theano.sparse.basic.HStack>` and ``hstack`` - :class:`HStack <theano.sparse.basic.HStack>` and ``hstack``.
- :class:`VStack <theano.sparse.basic.VStack>` and ``vstack`` The grad implemented is regular.
- :class:`VStack <theano.sparse.basic.VStack>` and ``vstack``.
The grad implemented is regular.
- Probability - Probability
`There is no grad implemented for these operations.`
- :class:`Poisson <theano.sparse.basic.Poisson>` and ``poisson`` - :class:`Poisson <theano.sparse.basic.Poisson>` and ``poisson``
- :class:`Binomial <theano.sparse.basic.Binomial>` and ``csc_fbinomial``, ``csc_dbinomial`` - :class:`Binomial <theano.sparse.basic.Binomial>` and ``csc_fbinomial``, ``csc_dbinomial``
``csr_fbinomial``, ``csr_dbinomial`` ``csr_fbinomial``, ``csr_dbinomial``
- :class:`Multinomial <theano.sparse.basic.Multinomial>` and ``multinomial`` - :class:`Multinomial <theano.sparse.basic.Multinomial>` and ``multinomial``
- Internal Representation - Internal Representation
`They all have a regular grad implemented.`
- :class:`EnsureSortedIndices <theano.sparse.basic.EnsureSortedIndices>` and ``ensure_sorted_indices`` - :class:`EnsureSortedIndices <theano.sparse.basic.EnsureSortedIndices>` and ``ensure_sorted_indices``
- :class:`Remove0 <theano.sparse.basic.Remove0>` and ``remove0`` - :class:`Remove0 <theano.sparse.basic.Remove0>` and ``remove0``
- ``clean`` to resort indices and remove zeros - :func:`clean <theano.sparse.basic.clean>` to resort indices and remove zeros
=================================================================== ===================================================================
:mod:`sparse` -- Sparse Op :mod:`sparse` -- Sparse Op
......
...@@ -233,12 +233,29 @@ def constant(x, name=None): ...@@ -233,12 +233,29 @@ def constant(x, name=None):
def sp_ones_like(x): def sp_ones_like(x):
"""Construct a sparse matrix of ones
with the same sparsity pattern.
:param x: Sparse matrix to take
the sparsity pattern.
:return: The same as `x` with data
changed for ones.
"""
# TODO: don't restrict to CSM formats # TODO: don't restrict to CSM formats
data, indices, indptr, shape = csm_properties(x) data, indices, indptr, shape = csm_properties(x)
return CSM(format=x.format)(tensor.ones_like(data), indices, indptr, shape) return CSM(format=x.format)(tensor.ones_like(data), indices, indptr, shape)
def sp_zeros_like(x): def sp_zeros_like(x):
"""Construct a sparse matrix of zeros.
:param x: Sparse matrix to take
the shape.
:return: The same as `x` with zero entries
for all element.
"""
#TODO: don't restrict to CSM formats #TODO: don't restrict to CSM formats
_, _, indptr, shape = csm_properties(x) _, _, indptr, shape = csm_properties(x)
return CSM(format=x.format)(numpy.array([], dtype=x.type.dtype), return CSM(format=x.format)(numpy.array([], dtype=x.type.dtype),
...@@ -2178,6 +2195,7 @@ class MulSS(gof.op.Op): ...@@ -2178,6 +2195,7 @@ class MulSS(gof.op.Op):
:return: `x` * `y` :return: `x` * `y`
:note: At least one of `x` and `y` must be a sparse matrix. :note: At least one of `x` and `y` must be a sparse matrix.
:note: The grad implemented is regular, i.e. not structured.
""" """
def __eq__(self, other): def __eq__(self, other):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论