Table Of Contents
Table Of Contents

NDArray

class mxnet.ndarray.NDArray(handle, writable=True)[source]

An array object representing a multidimensional, homogeneous array of fixed-size items.

Attributes

NDArray.context Device context of the array.
NDArray.dtype Data-type of the array’s elements.
NDArray.grad Returns gradient buffer attached to this NDArray.
NDArray.handle
NDArray.ndim Returns the number of dimensions of this array
NDArray.shape Tuple of array dimensions.
NDArray.size Number of elements in the array.
NDArray.stype Storage-type of the array.
NDArray.writable

Array creation

NDArray.ones_like(*args, **kwargs) Convenience fluent method for ones_like().
NDArray.zeros_like(*args, **kwargs) Convenience fluent method for zeros_like().

Manipulation

Array conversion

NDArray.as_in_context(context) Returns an array on the target device with the same value as this array.
NDArray.asnumpy() Returns a numpy.ndarray object with value copied from this array.
NDArray.asscalar() Returns a scalar whose value is copied from this array.
NDArray.astype(dtype[, copy]) Returns a copy of the array after casting to a specified type.
NDArray.copy() Makes a copy of this NDArray, keeping the same context.
NDArray.copyto(other) Copies the value of this array to another array.
NDArray.tostype(stype) Return a copy of the array with chosen storage type.

Changing shape

NDArray.diag([k]) Convenience fluent method for diag().
NDArray.expand_dims(*args, **kwargs) Convenience fluent method for expand_dims().
NDArray.flatten(*args, **kwargs) Convenience fluent method for flatten().
NDArray.reshape(*shape, **kwargs) Returns a view of this array with a new shape without altering any data.
NDArray.reshape_like(*args, **kwargs) Convenience fluent method for reshape_like().
NDArray.shape_array(*args, **kwargs) Convenience fluent method for shape_array().
NDArray.size_array(*args, **kwargs) Convenience fluent method for size_array().
NDArray.split(*args, **kwargs) Convenience fluent method for split().

Expanding elements

NDArray.broadcast_to(shape) Broadcasts the input array to a new shape.
NDArray.broadcast_axes(*args, **kwargs) Convenience fluent method for broadcast_axes().
NDArray.broadcast_like(other) Broadcasts the input array to the shape of other.
NDArray.pad(*args, **kwargs) Convenience fluent method for pad().
NDArray.repeat(*args, **kwargs) Convenience fluent method for repeat().
NDArray.tile(*args, **kwargs) Convenience fluent method for tile().

Rearrange elements

NDArray.depth_to_space(*args, **kwargs) Convenience fluent method for depth_to_space().
NDArray.flip(*args, **kwargs) Convenience fluent method for flip().
NDArray.swapaxes(*args, **kwargs) Convenience fluent method for swapaxes().
NDArray.space_to_depth(*args, **kwargs) Convenience fluent method for space_to_depth().
NDArray.T Returns a copy of the array with axes transposed.
NDArray.transpose(*args, **kwargs) Convenience fluent method for transpose().

Sorting and searching

NDArray.argmax(*args, **kwargs) Convenience fluent method for argmax().
NDArray.argmax_channel(*args, **kwargs) Convenience fluent method for argmax_channel().
NDArray.argmin(*args, **kwargs) Convenience fluent method for argmin().
NDArray.argsort(*args, **kwargs) Convenience fluent method for argsort().
NDArray.sort(*args, **kwargs) Convenience fluent method for sort().
NDArray.topk(*args, **kwargs) Convenience fluent method for topk().

Indexing

NDArray.__getitem__(key) x.__getitem__(i) <=> x[i]
NDArray.__setitem__(key, value) x.__setitem__(i, y) <=> x[i]=y
NDArray.one_hot(*args, **kwargs) Convenience fluent method for one_hot().
NDArray.pick(*args, **kwargs) Convenience fluent method for pick().
NDArray.slice(*args, **kwargs) Convenience fluent method for slice().
NDArray.slice_axis(*args, **kwargs) Convenience fluent method for slice_axis().
NDArray.slice_like(*args, **kwargs) Convenience fluent method for slice_like().
NDArray.take(*args, **kwargs) Convenience fluent method for take().

Lazy evaluation

NDArray.wait_to_read() Waits until all previous write operations on the current array are finished.

Math

Arithmetic operations

NDArray.__add__(other) x.__add__(y) <=> x+y <=> mx.nd.add(x, y)
NDArray.__div__(other) x.__div__(y) <=> x/y <=> mx.nd.divide(x, y)
NDArray.__neg__() x.__neg__(y) <=> -x
NDArray.__mod__(other) x.__mod__(y) <=> x%y <=> mx.nd.modulo(x, y)
NDArray.__mul__(other) x.__mul__(y) <=> x*y <=> mx.nd.multiply(x, y)
NDArray.__pow__(other) x.__pow__(y) <=> x**y <=> mx.nd.power(x,y)
NDArray.__rdiv__(other) x.__rdiv__(y) <=> y/x <=> mx.nd.divide(y, x)
NDArray.__rmod__(other) x.__rmod__(y) <=> y%x <=> mx.nd.modulo(y, x)
NDArray.__rsub__(other) x.__rsub__(y) <=> y-x <=> mx.nd.subtract(y, x)
NDArray.__sub__(other) x.__sub__(y) <=> x-y <=> mx.nd.subtract(x, y)

Rounding

NDArray.ceil(*args, **kwargs) Convenience fluent method for ceil().
NDArray.fix(*args, **kwargs) Convenience fluent method for fix().
NDArray.floor(*args, **kwargs) Convenience fluent method for floor().
NDArray.rint(*args, **kwargs) Convenience fluent method for rint().
NDArray.round(*args, **kwargs) Convenience fluent method for round().
NDArray.trunc(*args, **kwargs) Convenience fluent method for trunc().

Reduction

NDArray.max(*args, **kwargs) Convenience fluent method for max().
NDArray.mean(*args, **kwargs) Convenience fluent method for mean().
NDArray.min(*args, **kwargs) Convenience fluent method for min().
NDArray.nanprod(*args, **kwargs) Convenience fluent method for nanprod().
NDArray.nansum(*args, **kwargs) Convenience fluent method for nansum().
NDArray.norm(*args, **kwargs) Convenience fluent method for norm().
NDArray.prod(*args, **kwargs) Convenience fluent method for prod().
NDArray.sum(*args, **kwargs) Convenience fluent method for sum().

In^place arithmetic operations

NDArray.__iadd__(other) x.__iadd__(y) <=> x+=y
NDArray.__idiv__(other) x.__rdiv__(y) <=> x/=y
NDArray.__imod__(other) x.__rmod__(y) <=> x%=y
NDArray.__imul__(other) x.__imul__(y) <=> x*=y
NDArray.__isub__(other) x.__isub__(y) <=> x-=y

Comparison operators

NDArray.__eq__(other) x.__eq__(y) <=> x==y <=> mx.nd.equal(x, y)
NDArray.__ge__(other) x.__ge__(y) <=> x>=y <=> mx.nd.greater_equal(x, y)
NDArray.__gt__(other) x.__gt__(y) <=> x>y <=> mx.nd.greater(x, y)
NDArray.__le__(other) x.__le__(y) <=> x<=y <=> mx.nd.less_equal(x, y)
NDArray.__lt__(other) x.__lt__(y) <=> x<y <=> mx.nd.lesser(x, y)
NDArray.__ne__(other) x.__ne__(y) <=> x!=y <=> mx.nd.not_equal(x, y)

Trigonometric functions

NDArray.arccos(*args, **kwargs) Convenience fluent method for arccos().
NDArray.arcsin(*args, **kwargs) Convenience fluent method for arcsin().
NDArray.arctan(*args, **kwargs) Convenience fluent method for arctan().
NDArray.cos(*args, **kwargs) Convenience fluent method for cos().
NDArray.degrees(*args, **kwargs) Convenience fluent method for degrees().
NDArray.radians(*args, **kwargs) Convenience fluent method for radians().
NDArray.sin(*args, **kwargs) Convenience fluent method for sin().
NDArray.tan(*args, **kwargs) Convenience fluent method for tan().

Hyperbolic functions

NDArray.arccosh(*args, **kwargs) Convenience fluent method for arccosh().
NDArray.arcsinh(*args, **kwargs) Convenience fluent method for arcsinh().
NDArray.arctanh(*args, **kwargs) Convenience fluent method for arctanh().
NDArray.cosh(*args, **kwargs) Convenience fluent method for cosh().
NDArray.sinh(*args, **kwargs) Convenience fluent method for sinh().
NDArray.tanh(*args, **kwargs) Convenience fluent method for tanh().

Exponents and logarithms

NDArray.exp(*args, **kwargs) Convenience fluent method for exp().
NDArray.expm1(*args, **kwargs) Convenience fluent method for expm1().
NDArray.log(*args, **kwargs) Convenience fluent method for log().
NDArray.log1p(*args, **kwargs) Convenience fluent method for log1p().
NDArray.log10(*args, **kwargs) Convenience fluent method for log10().
NDArray.log2(*args, **kwargs) Convenience fluent method for log2().

Powers

NDArray.cbrt(*args, **kwargs) Convenience fluent method for cbrt().
NDArray.rcbrt(*args, **kwargs) Convenience fluent method for rcbrt().
NDArray.reciprocal(*args, **kwargs) Convenience fluent method for reciprocal().
NDArray.rsqrt(*args, **kwargs) Convenience fluent method for rsqrt().
NDArray.square(*args, **kwargs) Convenience fluent method for square().
NDArray.sqrt(*args, **kwargs) Convenience fluent method for sqrt().

Miscellaneous

NDArray.clip(*args, **kwargs) Convenience fluent method for clip().
NDArray.sign(*args, **kwargs) Convenience fluent method for sign().

Neural network

NDArray.log_softmax(*args, **kwargs) Convenience fluent method for log_softmax().
NDArray.relu(*args, **kwargs) Convenience fluent method for relu().
NDArray.sigmoid(*args, **kwargs) Convenience fluent method for sigmoid().
NDArray.softmax(*args, **kwargs) Convenience fluent method for softmax().