.. currentmodule:: mxnet.symbol.sparse
This document lists the routines of the sparse symbolic expression package:
.. autosummary:: :nosignatures: mxnet.symbol.sparse
The Sparse Symbol
API, defined in the symbol.sparse
package, provides sparse neural network graphs and auto-differentiation.
The storage type of a variable is speficied by the stype
attribute of the variable. The storage type of a symbolic expression is inferred based on the storage types of the variables and the operators.
>>> a = mx.sym.Variable('a', stype='csr') >>> b = mx.sym.Variable('b') >>> c = mx.sym.dot(a, b, transpose_a=True) >>> type(c) <class 'mxnet.symbol.Symbol'> >>> e = c.bind(mx.cpu(), {'a': mx.nd.array([[1,0,0]]).tostype('csr'), 'b':mx.nd.ones((1,2))}) >>> y = e.forward() # the result storage type of dot(csr.T, dense) is inferred to be `row_sparse` >>> y [<RowSparseNDArray 3x2 @cpu(0)>] >>> y[0].asnumpy() array([ 1., 1.], [ 0., 0.], [ 0., 0.]], dtype=float32)
.. note:: most operators provided in ``mxnet.symbol.sparse`` are similar to those in ``mxnet.symbol`` although there are few differences: - Only a subset of operators in ``mxnet.symbol`` have efficient sparse implementations in ``mxnet.symbol.sparse``. - If an operator do not occur in the ``mxnet.symbol.sparse`` namespace, that means the operator does not have an efficient sparse implementation yet. If sparse inputs are passed to such an operator, it will convert inputs to the dense format and fallback to the already available dense implementation. - The storage types (``stype``) of sparse operators' outputs depend on the storage types of inputs. By default the operators not available in ``mxnet.symbol.sparse`` infer "default" (dense) storage type for outputs. Please refer to the API reference section for further details on specific operators.
In the rest of this document, we list sparse related routines provided by the symbol.sparse
package.
.. autosummary:: :nosignatures: zeros_like mxnet.symbol.var
.. autosummary:: :nosignatures: cast_storage
.. autosummary:: :nosignatures: concat
.. autosummary:: :nosignatures: slice retain
.. autosummary:: :nosignatures: elemwise_add elemwise_sub elemwise_mul broadcast_add broadcast_sub broadcast_mul broadcast_div negative dot add_n
.. autosummary:: :nosignatures: sin tan arcsin arctan degrees radians
.. autosummary:: :nosignatures: sinh tanh arcsinh arctanh
.. autosummary:: :nosignatures: sum mean
.. autosummary:: :nosignatures: round rint fix floor ceil trunc
.. autosummary:: :nosignatures: expm1 log1p
.. autosummary:: :nosignatures: sqrt square
.. autosummary:: :nosignatures: clip abs sign
.. autosummary:: :nosignatures: make_loss stop_gradient Embedding LinearRegressionOutput LogisticRegressionOutput
.. automodule:: mxnet.symbol.sparse :members: