CSRNDArray¶
-
class
mxnet.ndarray.sparse.
CSRNDArray
(handle, writable=True)[source]¶ A sparse representation of 2D NDArray in the Compressed Sparse Row format.
A CSRNDArray represents an NDArray as three separate arrays: data, indptr and indices. It uses the CSR representation where the column indices for row i are stored in
indices[indptr[i]:indptr[i+1]]
and their corresponding values are stored indata[indptr[i]:indptr[i+1]]
.The column indices for a given row are expected to be sorted in ascending order. Duplicate column entries for the same row are not allowed.
Example
>>> a = mx.nd.array([[0, 1, 0], [2, 0, 0], [0, 0, 0], [0, 0, 3]]) >>> a = a.tostype('csr') >>> a.data.asnumpy() array([ 1., 2., 3.], dtype=float32) >>> a.indices.asnumpy() array([1, 0, 2]) >>> a.indptr.asnumpy() array([0, 1, 2, 2, 3])
See also
csr_matrix
Several ways to construct a CSRNDArray
Array attributes¶
Device context of the array. |
|
A deep copy NDArray of the data array of the CSRNDArray. |
|
Data-type of the array’s elements. |
|
A deep copy NDArray of the indices array of the CSRNDArray. |
|
A deep copy NDArray of the indptr array of the CSRNDArray. |
|
Tuple of array dimensions. |
|
Storage-type of the array. |
Array creation¶
Convenience fluent method for |
Manipulation¶
Array conversion¶
Returns an array on the target device with the same value as this array. |
|
Return a dense |
|
Returns a scalar whose value is copied from this array. |
|
Returns a |
|
Return a copy of the array after casting to a specified type. |
|
Makes a copy of this |
|
Copies the value of this array to another array. |
|
Return a copy of the array with chosen storage type. |
Array inspection¶
Check whether the NDArray format is valid. |
Array reduction¶
Convenience fluent method for |
|
Convenience fluent method for |
|
Convenience fluent method for |
Indexing¶
x.__getitem__(i) <=> x[i] |
|
x.__setitem__(i, y) <=> x[i]=y |
|
Convenience fluent method for |
Lazy evaluation¶
Waits until all previous write operations on the current array are finished. |
Math¶
Array rounding¶
Convenience fluent method for |
|
Convenience fluent method for |
|
Convenience fluent method for |
|
Convenience fluent method for |
|
Convenience fluent method for |
|
Convenience fluent method for |
Trigonometric functions¶
Convenience fluent method for |
|
Convenience fluent method for |
|
Convenience fluent method for |
|
Convenience fluent method for |
|
Convenience fluent method for |
|
Convenience fluent method for |
Hyperbolic functions¶
Convenience fluent method for |
|
Convenience fluent method for |
|
Convenience fluent method for |
|
Convenience fluent method for |
Exponents and logarithms¶
Convenience fluent method for |
|
Convenience fluent method for |