.. 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 on CPU.
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 specialized implementations in ``mxnet.symbol.sparse``. Operators such as reduction and broadcasting do not have sparse implementations yet. - 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. - GPU support for ``mxnet.symbol.sparse`` is experimental.
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: slice retain
.. autosummary:: :nosignatures: elemwise_add elemwise_sub elemwise_mul 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 mxnet.symbol.contrib.SparseEmbedding LinearRegressionOutput LogisticRegressionOutput
.. automodule:: mxnet.symbol.sparse :members: