Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sparse ndarray to NDArray.md #137

Merged
merged 1 commit into from
Aug 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 63 additions & 2 deletions docs/api/python/ndarray.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,21 @@ A detailed tutorial is available at
```

In the rest of this document, we first overview the methods provided by the
`ndarray.NDArray` class, and then list other routines provided by the
`ndarray` package.
`ndarray.NDArray` class and its subclasses, and then list other routines
provided by the `ndarray` package.

The `ndarray` package provides several classes:

```eval_rst
.. autosummary::
:nosignatures:
NDArray
CSRNDArray
RowSparseNDArray
```

We summarize the interface for each class in the following sections.

## The `NDArray` class

Expand All @@ -80,6 +92,7 @@ In the rest of this document, we first overview the methods provided by the
NDArray.size
NDArray.context
NDArray.dtype
NDArray.stype
```

### Array conversion
Expand Down Expand Up @@ -171,6 +184,33 @@ In the rest of this document, we first overview the methods provided by the
NDArray.wait_to_read
```

## The `RowSparseNDArray` Class

```eval_rst
.. autosummary::
:nosignatures:
RowSparseNDArray.copyto
RowSparseNDArray.__setitem__
RowSparseNDArray.__getitem__
RowSparseNDArray.data
RowSparseNDArray.indices
```

## The `CSRNDArray` Class

```eval_rst
.. autosummary::
:nosignatures:
CSRNDArray.copyto
CSRNDArray.__setitem__
CSRNDArray.__getitem__
CSRNDArray.data
CSRNDArray.indices
CSRNDArray.indptr
```

## Array creation routines

```eval_rst
Expand Down Expand Up @@ -499,8 +539,29 @@ The `contrib.ndarray` module contains many useful experimental APIs for new feat
<script type="text/javascript" src='../../_static/js/auto_module_index.js'></script>

```eval_rst
.. autoclass:: mxnet.ndarray.NDArray
:members:
:special-members:
.. autoclass:: mxnet.ndarray.BaseSparseNDArray
:members:
:special-members:
:exclude-members: __weakref__
.. autoclass:: mxnet.ndarray.CSRNDArray
:members:
:special-members:
.. autoclass:: mxnet.ndarray.RowSparseNDArray
:members:
:special-members:
.. automodule:: mxnet.ndarray
:members:
:imported-members:
:special-members:
:exclude-members: CachedOp, BaseSparseNDArray, NDArray, CSRNDArray, RowSparseNDArray
.. automodule:: mxnet.random
:members:
Expand Down
12 changes: 5 additions & 7 deletions python/mxnet/ndarray/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""ndarray module"""
"""NDArray API of MXNet."""

from . import _internal
from . import op
from .op import CachedOp
from .ndarray import NDArray, concatenate, _DTYPE_NP_TO_MX, _DTYPE_MX_TO_NP
from .ndarray import ones, add, arange, divide, equal, full, greater, greater_equal, imdecode
from .ndarray import lesser, lesser_equal, maximum, minimum, moveaxis, multiply, negative, not_equal
from .ndarray import onehot_encode, power, subtract, true_divide, waitall, _new_empty_handle
# pylint: disable=wildcard-import
from .ndarray import *
from .ndarray_utils import load, save, zeros, empty, array
from .sparse_ndarray import _ndarray_cls, todense
from .sparse_ndarray import csr, row_sparse, BaseSparseNDArray, RowSparseNDArray, CSRNDArray
from .sparse_ndarray import _ndarray_cls
from .sparse_ndarray import csr, row_sparse, BaseSparseNDArray, todense, RowSparseNDArray, CSRNDArray
8 changes: 8 additions & 0 deletions python/mxnet/ndarray/ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
from . import broadcast_greater, broadcast_greater_equal, broadcast_lesser, broadcast_lesser_equal
from . import zeros_like, slice

__all__ = ["NDArray", "concatenate", "_DTYPE_NP_TO_MX", "_DTYPE_MX_TO_NP", \
"ones", "add", "arange", "divide", "equal", "full", "greater", "greater_equal", \
"imdecode", "lesser", "lesser_equal", "maximum", "minimum", "moveaxis", \
"multiply", "negative", "not_equal", "onehot_encode", "power", "subtract", \
"true_divide", "waitall", "_new_empty_handle"]

# pylint: disable= no-member
_DTYPE_NP_TO_MX = {
None : -1,
Expand Down Expand Up @@ -819,6 +825,8 @@ def dtype(self):

@property
def stype(self):
"""Storage-type of the array.
"""
return _storage_type(self.handle)

@property
Expand Down
Loading