NDArray

The core MXNet data structure for all mathematical operations

Get array attributes

dim.MXNDArray

Dimension operator overload of mx.ndarray

is.mx.ndarray

Check if src.array is mx.ndarray

length.MXNDArray

Length operator overload of mx.ndarray

mx.nd.shape.array

Returns a 1D int64 array containing the shape of data

mx.nd.size.array

Returns a 1D int64 array containing the size of data

print.MXNDArray

print operator overload of mx.ndarray

Create arrays

mx.nd.array

Create a new mx.ndarray that copies the content from src on ctx

mx.nd.one.hot

Returns a one-hot array

mx.nd.ones

Generate an mx.ndarray object with ones

mx.nd.ones.like

Return an array of ones with the same shape and type as the input array

mx.nd.zeros

Generate an mx.nd.array object with zeros

mx.nd.zeros.like

Return an array of zeros with the same shape, type and storage type as the input array

Manipulation of arrays

Conversion

Ops.MXNDArray

Binary operator overloading of mx.ndarray

as.array.MXNDArray

as.array operator overload of mx.ndarray

as.matrix.MXNDArray

as.matrix operator overload of mx.ndarray

mx.nd.Cast

Casts all elements of the input to a new type

mx.nd.amp.cast

Cast function between low precision float/FP32 used by AMP

mx.nd.cast.storage

Casts tensor storage type to the new type

mx.nd.copyto

Generate an mx.ndarray object on ctx, with data copied from src

mx.nd.load

Load an mx.nd.array object on disk

mx.nd.save

Save an mx.nd.array object

Reshaping

mx.nd.Concat

Joins input arrays along a given axis

mx.nd.Reshape

Reshapes the input array

mx.nd.flatten

Flattens the input array into a 2-D array by collapsing the higher dimensions

mx.nd.reshape.like

Reshape some or all dimensions of lhs to have the same shape as some or all dimensions of rhs

mx.nd.scatter.nd

Scatters data into a new tensor according to indices

mx.nd.split

Splits an array along a particular axis into multiple sub-arrays

mx.nd.squeeze

Remove single-dimensional entries from the shape of an array

mx.nd.stack

Join a sequence of arrays along a new axis

Expanding elements

mx.nd.GridGenerator

Generates 2D sampling grid for bilinear sampling

mx.nd.UpSampling

Upsamples the given input data

mx.nd.broadcast.add

Returns element-wise sum of the input arrays with broadcasting

mx.nd.broadcast.axes

Broadcasts the input array over particular axes

mx.nd.broadcast.axis

Broadcasts the input array over particular axes

mx.nd.broadcast.div

Returns element-wise division of the input arrays with broadcasting

mx.nd.broadcast.equal

Returns the result of element-wise equal to (==) comparison operation with broadcasting

mx.nd.broadcast.greater

Returns the result of element-wise greater than (>) comparison operation with broadcasting

mx.nd.broadcast.greater.equal

Returns the result of element-wise greater than or equal to (>=) comparison operation with broadcasting

mx.nd.broadcast.hypot

Returns the hypotenuse of a right angled triangle, given its “legs” with broadcasting

mx.nd.broadcast.lesser

Returns the result of element-wise lesser than (<) comparison operation with broadcasting

mx.nd.broadcast.lesser.equal

Returns the result of element-wise lesser than or equal to (<=) comparison operation with broadcasting

mx.nd.broadcast.like

Broadcasts lhs to have the same shape as rhs

mx.nd.broadcast.logical.and

Returns the result of element-wise logical and with broadcasting

mx.nd.broadcast.logical.or

Returns the result of element-wise logical or with broadcasting

mx.nd.broadcast.logical.xor

Returns the result of element-wise logical xor with broadcasting

mx.nd.broadcast.maximum

Returns element-wise maximum of the input arrays with broadcasting

mx.nd.broadcast.minimum

Returns element-wise minimum of the input arrays with broadcasting

mx.nd.broadcast.minus

Returns element-wise difference of the input arrays with broadcasting

mx.nd.broadcast.mod

Returns element-wise modulo of the input arrays with broadcasting

mx.nd.broadcast.mul

Returns element-wise product of the input arrays with broadcasting

mx.nd.broadcast.not.equal

Returns the result of element-wise not equal to (!=) comparison operation with broadcasting

mx.nd.broadcast.plus

Returns element-wise sum of the input arrays with broadcasting

mx.nd.broadcast.power

Returns result of first array elements raised to powers from second array, element-wise with broadcasting

mx.nd.broadcast.sub

Returns element-wise difference of the input arrays with broadcasting

mx.nd.broadcast.to

Broadcasts the input array to a new shape

mx.nd.expand.dims

Inserts a new axis of size 1 into the array shape For example, given x with shape (2,3,4), then expand_dims(x, axis=1) will return a new array with shape (2,1,3,4)

mx.nd.pad

Pads an input array with a constant or edge values of the array

mx.nd.repeat

Repeats elements of an array

mx.nd.tile

Repeats the whole array multiple times

Rearranging elements

mx.nd.SequenceReverse

Reverses the elements of each sequence

mx.nd.SwapAxis

Interchanges two axes of an array

mx.nd.depth.to.space

Rearranges(permutes) data from depth into blocks of spatial data

mx.nd.flip

Reverses the order of elements along given axis while preserving array shape

mx.nd.reverse

Reverses the order of elements along given axis while preserving array shape

mx.nd.shuffle

Randomly shuffle the elements

mx.nd.space.to.depth

Rearranges(permutes) blocks of spatial data into depth

mx.nd.swapaxes

Interchanges two axes of an array

mx.nd.transpose

Permutes the dimensions of an array

Sorting and searching

mx.nd.argmax

Returns indices of the maximum values along an axis

mx.nd.argmax.channel

Returns argmax indices of each channel from the input array

mx.nd.argmin

Returns indices of the minimum values along an axis

mx.nd.argsort

Returns the indices that would sort an input array along the given axis

mx.nd.sort

Returns a sorted copy of an input array along the given axis

mx.nd.topk

Returns the indices of the top k elements in an input array along the given axis (by default)

mx.nd.where

Return the elements, either from x or y, depending on the condition

Indexing

mx.nd.SequenceLast

Takes the last element of a sequence

mx.nd.SequenceMask

Sets all elements outside the sequence to a constant value

mx.nd.SliceChannel

Splits an array along a particular axis into multiple sub-arrays

mx.nd.batch.take

Takes elements from a data batch

mx.nd.choose.element.0index

Picks elements from an input array according to the input indices along the given axis

mx.nd.crop

Slices a region of the array

mx.nd.diag

Extracts a diagonal or constructs a diagonal array

mx.nd.fill.element.0index

Fill one element of each line(row for python, column for R/Julia) in lhs according to index indicated by rhs and values indicated by mhs

mx.nd.gather.nd

Gather elements or slices from data and store to a tensor whose shape is defined by indices

mx.nd.pick

Picks elements from an input array according to the input indices along the given axis

mx.nd.ravel.multi.index

Converts a batch of index arrays into an array of flat indices

mx.nd.slice.axis

Slices along a given axis

mx.nd.slice.like

Slices a region of the array like the shape of another array

mx.nd.take

Takes elements from an input array along the given axis

mx.nd.unravel.index

Converts an array of flat indices into a batch of index arrays

Mathematical operations on arrays

Arithmetic

mx.nd.ElementWiseSum

Adds all input arguments element-wise

mx.nd.GroupNorm

Group normalization

mx.nd.abs

Returns element-wise absolute value of the input

mx.nd.add.n

Adds all input arguments element-wise

mx.nd.all.finite

Check if all the float numbers in the array are finite (used for AMP)

mx.nd.cbrt

Returns element-wise cube-root value of the input

mx.nd.cumsum

Return the cumulative sum of the elements along a given axis

mx.nd.elemwise.add

Adds arguments element-wise

mx.nd.elemwise.div

Divides arguments element-wise

mx.nd.elemwise.mul

Multiplies arguments element-wise

mx.nd.elemwise.sub

Subtracts arguments element-wise

mx.nd.erf

Returns element-wise gauss error function of the input

mx.nd.erfinv

Returns element-wise inverse gauss error function of the input

mx.nd.exp

Returns element-wise exponential value of the input

mx.nd.expm1

Returns exp(x) - 1 computed element-wise on the input

mx.nd.gamma

Returns the gamma function (extension of the factorial function to the reals), computed element-wise on the input array

mx.nd.gammaln

Returns element-wise log of the absolute value of the gamma function of the input

mx.nd.identity

Returns a copy of the input

mx.nd.log

Returns element-wise Natural logarithmic value of the input

mx.nd.log10

Returns element-wise Base-10 logarithmic value of the input

mx.nd.log1p

Returns element-wise log(1 + x) value of the input

mx.nd.log2

Returns element-wise Base-2 logarithmic value of the input

mx.nd.logical.not

Returns the result of logical NOT (!) function

mx.nd.moments

Calculate the mean and variance of data

mx.nd.multi.all.finite

Check if all the float numbers in all the arrays are finite (used for AMP)

mx.nd.multi.lars

Compute the LARS coefficients of multiple weights and grads from their sums of square”

mx.nd.multi.sum.sq

Compute the sums of squares of multiple arrays

mx.nd.negative

Numerical negative of the argument, element-wise

mx.nd.rcbrt

Returns element-wise inverse cube-root value of the input

mx.nd.reciprocal

Returns the reciprocal of the argument, element-wise

mx.nd.reset.arrays

Set to zero multiple arrays

mx.nd.rsqrt

Returns element-wise inverse square-root value of the input

mx.nd.sign

Returns element-wise sign of the input

mx.nd.sqrt

Returns element-wise square-root value of the input

mx.nd.square

Returns element-wise squared value of the input

Reduce

mx.nd.max

Computes the max of array elements over given axes

mx.nd.max.axis

Computes the max of array elements over given axes

mx.nd.mean

Computes the mean of array elements over given axes

mx.nd.min

Computes the min of array elements over given axes

mx.nd.min.axis

Computes the min of array elements over given axes

mx.nd.nanprod

Computes the product of array elements over given axes treating Not a Numbers (NaN) as one

mx.nd.nansum

Computes the sum of array elements over given axes treating Not a Numbers (NaN) as zero

mx.nd.prod

Computes the product of array elements over given axes

mx.nd.sum

Computes the sum of array elements over given axes

mx.nd.sum.axis

Computes the sum of array elements over given axes

Round

mx.nd.ceil

Returns element-wise ceiling of the input

mx.nd.clip

Clips (limits) the values in an array

mx.nd.fix

Returns element-wise rounded value to the nearest integer towards zero of the input

mx.nd.floor

Returns element-wise floor of the input

mx.nd.rint

Returns element-wise rounded value to the nearest integer of the input

mx.nd.round

Returns element-wise rounded value to the nearest integer of the input

mx.nd.trunc

Return the element-wise truncated value of the input

Linear algebra

mx.nd.L2Normalization

Normalize the input array using the L2 norm

mx.nd.batch.dot

Batchwise dot product

mx.nd.dot

Dot product of two arrays

mx.nd.khatri.rao

Computes the Khatri-Rao product of the input matrices

mx.nd.linalg.det

Compute the determinant of a matrix

mx.nd.linalg.extractdiag

Extracts the diagonal entries of a square matrix

mx.nd.linalg.extracttrian

Extracts a triangular sub-matrix from a square matrix

mx.nd.linalg.gelqf

LQ factorization for general matrix

mx.nd.linalg.gemm

Performs general matrix multiplication and accumulation

mx.nd.linalg.gemm2

Performs general matrix multiplication

mx.nd.linalg.inverse

Compute the inverse of a matrix

mx.nd.linalg.makediag

Constructs a square matrix with the input as diagonal

mx.nd.linalg.maketrian

Constructs a square matrix with the input representing a specific triangular sub-matrix

mx.nd.linalg.potrf

Performs Cholesky factorization of a symmetric positive-definite matrix

mx.nd.linalg.potri

Performs matrix inversion from a Cholesky factorization

mx.nd.linalg.slogdet

Compute the sign and log of the determinant of a matrix

mx.nd.linalg.sumlogdiag

Computes the sum of the logarithms of the diagonal elements of a square matrix

mx.nd.linalg.syrk

Multiplication of matrix with its transpose

mx.nd.linalg.trmm

Performs multiplication with a lower triangular matrix

mx.nd.linalg.trsm

Solves matrix equation involving a lower triangular matrix

mx.nd.norm

Computes the norm on an NDArray

mx.nd.smooth.l1

Calculate Smooth L1 Loss(lhs, scalar) by summing

Trigonometric functions

mx.nd.arccos

Returns element-wise inverse cosine of the input array

mx.nd.arcsin

Returns element-wise inverse sine of the input array

mx.nd.arctan

Returns element-wise inverse tangent of the input array

mx.nd.cos

Computes the element-wise cosine of the input array

mx.nd.degrees

Converts each element of the input array from radians to degrees

mx.nd.radians

Converts each element of the input array from degrees to radians

mx.nd.sin

Computes the element-wise sine of the input array

mx.nd.tan

Computes the element-wise tangent of the input array

Hyperbolic functions

mx.nd.arccosh

Returns the element-wise inverse hyperbolic cosine of the input array, computed element-wise

mx.nd.arcsinh

Returns the element-wise inverse hyperbolic sine of the input array, computed element-wise

mx.nd.arctanh

Returns the element-wise inverse hyperbolic tangent of the input array, computed element-wise

mx.nd.cosh

Returns the hyperbolic cosine of the input array, computed element-wise

mx.nd.sinh

Returns the hyperbolic sine of the input array, computed element-wise

mx.nd.tanh

Returns the hyperbolic tangent of the input array, computed element-wise

Neural network array operations

mx.nd.Activation

Applies an activation function element-wise to the input

mx.nd.BatchNorm

Batch normalization

mx.nd.BatchNorm.v1

Batch normalization

mx.nd.BlockGrad

Stops gradient computation

mx.nd.CTCLoss

Connectionist Temporal Classification Loss

mx.nd.Convolution

Compute N-D convolution on (N+2)-D input

mx.nd.Convolution.v1

This operator is DEPRECATED

mx.nd.Correlation

Applies correlation to inputs

mx.nd.Custom

Apply a custom operator implemented in a frontend language (like Python)

mx.nd.Deconvolution

Computes 1D or 2D transposed convolution (aka fractionally strided convolution) of the input tensor

mx.nd.Dropout

Applies dropout operation to input array

mx.nd.Embedding

Maps integer indices to vector representations (embeddings)

mx.nd.FullyConnected

Applies a linear transformation: \(Y = XW^T + b\)

mx.nd.IdentityAttachKLSparseReg

Apply a sparse regularization to the output a sigmoid activation function

mx.nd.InstanceNorm

Applies instance normalization to the n-dimensional input array

mx.nd.LRN

Applies local response normalization to the input

mx.nd.LayerNorm

Layer normalization

mx.nd.LeakyReLU

Applies Leaky rectified linear unit activation element-wise to the input

mx.nd.LinearRegressionOutput

Computes and optimizes for squared loss during backward propagation

mx.nd.LogisticRegressionOutput

Applies a logistic function to the input

mx.nd.MAERegressionOutput

Computes mean absolute error of the input

mx.nd.MakeLoss

Make your own loss function in network construction

mx.nd.Pooling

Performs pooling on the input

mx.nd.Pooling.v1

This operator is DEPRECATED

mx.nd.RNN

Applies recurrent layers to input data

mx.nd.ROIPooling

Performs region of interest(ROI) pooling on the input array

mx.nd.SVMOutput

Computes support vector machine based transformation of the input

mx.nd.Softmax

Computes the gradient of cross entropy loss with respect to softmax output

mx.nd.SoftmaxActivation

Applies softmax activation to input

mx.nd.SoftmaxOutput

Computes the gradient of cross entropy loss with respect to softmax output

mx.nd.SpatialTransformer

Applies a spatial transformer to input feature map

mx.nd.ctc.loss

Connectionist Temporal Classification Loss

mx.nd.hard.sigmoid

Computes hard sigmoid of x element-wise

mx.nd.log.softmax

Computes the log softmax of the input

mx.nd.make.loss

Make your own loss function in network construction

mx.nd.relu

Computes rectified linear activation

mx.nd.sigmoid

Computes sigmoid of x element-wise

mx.nd.softmax.cross.entropy

Calculate cross entropy of softmax output and one-hot label

mx.nd.softmin

Applies the softmin function

mx.nd.softsign

Computes softsign of x element-wise

mx.nd.stop.gradient

Stops gradient computation