Table Of Contents
Table Of Contents

Routines

Create Arrays

arange

Returns evenly spaced values within a given interval.

array

Creates an array from any object exposing the array interface.

diag

Extracts a diagonal or constructs a diagonal array.

empty

Returns a new array of given shape and type, without initializing entries.

full

Returns a new array of given shape and type, filled with the given value val.

load

Loads an array from file.

ones

Returns a new array filled with all ones, with the given shape and type.

ones_like

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

save

Saves a list of arrays or a dict of str->array to file.

zeros

Return a new array of given shape and type, filled with zeros.

zeros_like

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

Manipulate

Change shape and type

cast

Casts all elements of the input to a new type.

flatten

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

expand_dims

Inserts a new axis of size 1 into the array shape

reshape

Reshapes the input array.

reshape_like

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

shape_array

Returns a 1D int64 array containing the shape of data.

size_array

Returns a 1D int64 array containing the size of data.

Expand elements

broadcast_axes

Broadcasts the input array over particular axes.

broadcast_like

Broadcasts lhs to have the same shape as rhs.

broadcast_to

Broadcasts the input array to a new shape.

pad

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

repeat

Repeats elements of an array.

tile

Repeats the whole array multiple times.

Rearrange elements

depth_to_space

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

flip

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

space_to_depth

Rearranges(permutes) blocks of spatial data into depth.

swapaxes

Interchanges two axes of an array.

transpose

Permutes the dimensions of an array.

Join and split

concat

Joins input arrays along a given axis.

split

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

stack

Join a sequence of arrays along a new axis.

Index

batch_take

Takes elements from a data batch.

one_hot

Returns a one-hot array.

pick

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

ravel_multi_index

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

slice

Slices a region of the array.

slice_axis

Slices along a given axis.

slice_like

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

take

Takes elements from an input array along the given axis.

unravel_index

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

where

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

Sequence

SequenceLast([data, sequence_length, …])

Takes the last element of a sequence.

SequenceMask([data, sequence_length, …])

Sets all elements outside the sequence to a constant value.

SequenceReverse([data, sequence_length, …])

Reverses the elements of each sequence.

Math

Arithmetic

add

Returns element-wise sum of the input arrays with broadcasting.

add_n

Adds all input arguments element-wise.

batch_dot

Batchwise dot product.

divide

Returns element-wise division of the input arrays with broadcasting.

dot

Dot product of two arrays.

modulo

Returns element-wise modulo of the input arrays with broadcasting.

multiply

Returns element-wise product of the input arrays with broadcasting.

negative

Numerical negative of the argument, element-wise.

subtract

Returns element-wise difference of the input arrays with broadcasting.

Trigonometric

arccos

Returns element-wise inverse cosine of the input array.

arcsin

Returns element-wise inverse sine of the input array.

arctan

Returns element-wise inverse tangent of the input array.

broadcast_hypot

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

degrees

Converts each element of the input array from radians to degrees.

cos

Computes the element-wise cosine of the input array.

radians

Converts each element of the input array from degrees to radians.

sin

Computes the element-wise sine of the input array.

tan

Computes the element-wise tangent of the input array.

Hyperbolic

arcsinh

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

arccosh

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

arctanh

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

cosh

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

sinh

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

tanh

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

Reduce

max

Computes the max of array elements over given axes.

min

Computes the min of array elements over given axes.

mean

Computes the mean of array elements over given axes.

nanprod

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

nansum

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

norm

Computes the norm on an NDArray.

prod

Computes the product of array elements over given axes.

sum

Computes the sum of array elements over given axes.

Round

ceil

Returns element-wise ceiling of the input.

fix

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

floor

Returns element-wise floor of the input.

round

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

rint

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

trunc

Return the element-wise truncated value of the input.

Exponents and logarithms

exp

Returns element-wise exponential value of the input.

expm1

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

log

Returns element-wise Natural logarithmic value of the input.

log1p

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

log10

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

log2

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

Powers

cbrt

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

power

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

rcbrt

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

reciprocal

Returns the reciprocal of the argument, element-wise.

rsqrt

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

square

Returns element-wise squared value of the input.

sqrt

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

Compare

equal

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

greater

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

greater_equal

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

lesser

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

lesser_equal

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

not_equal

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

Logical

logical_and

Returns the result of element-wise logical and comparison operation with broadcasting.

logical_not

Returns the result of logical NOT (!) function

logical_or

Returns the result of element-wise logical or comparison operation with broadcasting.

logical_xor

Returns the result of element-wise logical xor comparison operation with broadcasting.

Random Distribution

random.exponential

Draw samples from an exponential distribution.

random.gamma

Draw random samples from a gamma distribution.

random.generalized_negative_binomial

Draw random samples from a generalized negative binomial distribution.

random.multinomial

Concurrent sampling from multiple multinomial distributions.

random.negative_binomial

Draw random samples from a negative binomial distribution.

random.normal

Draw random samples from a normal (Gaussian) distribution.

random.poisson

Draw random samples from a Poisson distribution.

random.randint

Draw random samples from a discrete uniform distribution.

random.randn

Draw random samples from a normal (Gaussian) distribution.

random.shuffle

Shuffle the elements randomly.

random.uniform

Draw random samples from a uniform distribution.

Linear Algebra

linalg.gelqf

LQ factorization for general matrix.

linalg.gemm

Performs general matrix multiplication and accumulation.

linalg.gemm2

Performs general matrix multiplication.

linalg.potrf

Performs Cholesky factorization of a symmetric positive-definite matrix.

linalg.potri

Performs matrix inversion from a Cholesky factorization.

linalg.sumlogdiag

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

linalg.syevd

Eigendecomposition for symmetric matrix.

linalg.syrk

Multiplication of matrix with its transpose.

linalg.trmm

Performs multiplication with a lower triangular matrix.

linalg.trsm

Solves matrix equation involving a lower triangular matrix.

Miscellaneous

abs([data, out, name])

Returns element-wise absolute value of the input.

clip([data, a_min, a_max, out, name])

Clips (limits) the values in an array.

gamma([data, out, name])

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

gammaln([data, out, name])

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

maximum(lhs, rhs)

Returns element-wise maximum of the input arrays with broadcasting.

minimum(lhs, rhs)

Returns element-wise minimum of the input arrays with broadcasting.

sign([data, out, name])

Returns element-wise sign of the input.

Neural Network

Activation([data, act_type, out, name])

Applies an activation function element-wise to the input.

BatchNorm([data, gamma, beta, moving_mean, …])

Batch normalization.

BilinearSampler([data, grid, cudnn_off, …])

Applies bilinear sampling to input feature map.

BlockGrad([data, out, name])

Stops gradient computation.

Convolution([data, weight, bias, kernel, …])

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

Correlation([data1, data2, kernel_size, …])

Applies correlation to inputs.

Custom(*data, **kwargs)

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

Deconvolution([data, weight, bias, kernel, …])

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

Dropout([data, p, mode, axes, out, name])

Applies dropout operation to input array.

Embedding([data, weight, input_dim, …])

Maps integer indices to vector representations (embeddings).

FullyConnected([data, weight, bias, …])

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

GridGenerator([data, transform_type, …])

Generates 2D sampling grid for bilinear sampling.

IdentityAttachKLSparseReg([data, …])

Apply a sparse regularization to the output a sigmoid activation function.

InstanceNorm([data, gamma, beta, eps, out, name])

Applies instance normalization to the n-dimensional input array.

L2Normalization([data, eps, mode, out, name])

Normalize the input array using the L2 norm.

LayerNorm([data, gamma, beta, axis, eps, …])

Layer normalization.

LeakyReLU([data, gamma, act_type, slope, …])

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

LinearRegressionOutput([data, label, …])

Computes and optimizes for squared loss during backward propagation.

log_softmax([data, axis, temperature, out, name])

Computes the log softmax of the input.

LogisticRegressionOutput([data, label, …])

Applies a logistic function to the input.

LRN([data, alpha, beta, knorm, nsize, out, name])

Applies local response normalization to the input.

MAERegressionOutput([data, label, …])

Computes mean absolute error of the input.

MakeLoss([data, grad_scale, valid_thresh, …])

Make your own loss function in network construction.

Pooling([data, kernel, pool_type, …])

Performs pooling on the input.

relu([data, out, name])

Computes rectified linear.

ROIPooling([data, rois, pooled_size, …])

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

RNN([data, parameters, state, state_cell, …])

Applies recurrent layers to input data.

sigmoid([data, out, name])

Computes sigmoid of x element-wise.

smooth_l1([data, scalar, out, name])

Calculate Smooth L1 Loss(lhs, scalar) by summing

softmax([data, axis, temperature, out, name])

Applies the softmax function.

softmax_cross_entropy([data, label, out, name])

Calculate cross entropy of softmax output and one-hot label.

SoftmaxOutput([data, label, grad_scale, …])

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

SoftmaxActivation([data, mode, out, name])

Applies softmax activation to input.

SpatialTransformer([data, loc, …])

Applies a spatial transformer to input feature map.

SVMOutput([data, label, margin, …])

Computes support vector machine based transformation of the input.

UpSampling(*data, **kwargs)

Performs nearest neighbor/bilinear up sampling to inputs.

Contributed routines

Contrib NDArray API of MXNet.

Note

This package contains experimental APIs and may change in the near future.

Manipulate

count_sketch

Apply CountSketch to input: map a d-dimension data to k-dimension data”

getnnz

Number of stored values for a sparse tensor, including explicit zeros.

index_copy

Copies the elements of a new_tensor into the old_tensor.

FFT

fft

Apply 1D FFT to input”

ifft

Apply 1D ifft to input”

Quantization

dequantize

Dequantize the input tensor into a float tensor.

quantize

Quantize a input tensor from float to out_type, with user-specified min_range and max_range.

Neural network

AdaptiveAvgPooling2D

Applies a 2D adaptive average pooling over a 4D input with the shape of (NCHW).

BilinearResize2D

Perform 2D resizing (upsampling or downsampling) for 4D input using bilinear interpolation.

ctc_loss

Connectionist Temporal Classification Loss.

DeformableConvolution

Compute 2-D deformable convolution on 4-D input.

DeformablePSROIPooling

Performs deformable position-sensitive region-of-interest pooling on inputs.

MultiBoxDetection

Convert multibox detection predictions.

MultiBoxPrior

Generate prior(anchor) boxes from data, sizes and ratios.

MultiBoxTarget

Compute Multibox training targets

MultiProposal

Generate region proposals via RPN

Proposal

Generate region proposals via RPN

PSROIPooling

Performs region-of-interest pooling on inputs.

ROIAlign

This operator takes a 4D feature map as an input array and region proposals as rois, then align the feature map over sub-regions of input and produces a fixed-sized output array.

Control flow

cond

Run an if-then-else using user-defined condition and computation

foreach

Run a for loop with user-defined computation over NDArrays on dimension 0.

while_loop

Run a while loop with user-defined computation and loop condition.