提交 962285da authored 作者: Frederic's avatar Frederic

Add documentation about the fct csm_data, csm_indices, csm_indptr, csm_shape,…

Add documentation about the fct csm_data, csm_indices, csm_indptr, csm_shape, csm_properties and theano.sparse.tests.test_basic.sparse_random_inputs.
上级 d26e550b
......@@ -127,8 +127,10 @@ List of Implemented Operations
- Construction of Sparses and their Properties
- :class:`CSM <theano.sparse.basic.CSM>` and ``CSC``, ``CSR`` to construct a matrix.
The grad implemented is regular.
- :class:`CSMProperties <theano.sparse.basic.CSMProperties>` to get the properties of a sparse matrix.
- :class:`CSMProperties <theano.sparse.basic.CSMProperties>` and ``csm_properties(x)``
to get the properties of a sparse matrix.
The grad implemented is regular.
- csm_indices(x), csm_indptr(x), csm_data(x) and csm_shape(x) or x.shape.
- :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>`.
......@@ -259,6 +261,9 @@ List of Implemented Operations
- :class:`Remove0 <theano.sparse.basic.Remove0>` and ``remove0``
- :func:`clean <theano.sparse.basic.clean>` to resort indices and remove zeros
- To help testing
- :func:`theano.sparse.tests.test_basic.sparse_random_inputs`
===================================================================
:mod:`sparse` -- Sparse Op
===================================================================
......@@ -271,3 +276,4 @@ List of Implemented Operations
.. automodule:: theano.sparse.basic
:members:
.. autofunction:: theano.sparse.tests.test_basic.sparse_random_inputs
......@@ -511,23 +511,42 @@ class CSMProperties(gof.Op):
data, indices, indptr, shape = csm_properties(csm)
return [CSM(csm.format)(g[0], indices, indptr, shape)]
# don't make this a function or it breaks some optimizations below
csm_properties = CSMProperties()
"""An CSMProperties object instance. It return the fields data,
indices, indptr and shape of the sparse varible. Together they specify
completly the the sparse variable when we know its format. Example::
the_data, the_indices, the_indptr, the_shape = csm_properties(a_sparse_var)
"""
def csm_data(csm):
"""
return the data field of the sparse variable.
"""
return csm_properties(csm)[0]
def csm_indices(csm):
"""
return the indices field of the sparse variable.
"""
return csm_properties(csm)[1]
def csm_indptr(csm):
"""
return the indptr field of the sparse variable.
"""
return csm_properties(csm)[2]
def csm_shape(csm):
"""
return the shape field of the sparse variable.
"""
return csm_properties(csm)[3]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论