mindspore.numpy
Numpy-like interfaces in mindspore.
Examples
>>> import mindspore.numpy as np
Note
array_ops.py defines all the array operation interfaces.
array_creations.py defines all the array generation interfaces.
math_ops.py defines all the math operations on tensors.
logic_ops.py defines all the logical operations on tensors.
dtypes.py defines all the mindspore.numpy dtypes (mainly redirected from mindspore)
Array Generation
API Name |
Description |
Supported Platforms |
|
Returns evenly spaced values within a given interval. |
|
|
Creates a tensor. |
|
|
Converts the input to tensor. |
|
|
Similar to asarray, converts the input to a float tensor. |
|
|
Returns a tensor copy of the given object. |
|
|
Returns a new array of given shape and type, without initializing entries. |
|
|
Returns a new array with the same shape and type as a given array. |
|
|
Returns a 2-D tensor with ones on the diagnoal and zeros elsewhere. |
|
|
Returns a new tensor of given shape and type, filled with fill_value. |
|
|
Returns a full array with the same shape and type as a given array. |
|
|
Returns the identity tensor. |
|
|
Constructs an open mesh from multiple sequences. |
|
|
Returns evenly spaced values within a given interval. |
|
|
Returns numbers spaced evenly on a log scale. |
|
|
Returns coordinate matrices from coordinate vectors. |
|
|
mgrid is an |
|
|
ogrid is an |
|
|
Returns a new tensor of given shape and type, filled with ones. |
|
|
Returns an array of ones with the same shape and type as a given array. |
|
|
Returns a tensor with ones at and below the given diagonal and zeros elsewhere. |
|
|
Returns a lower triangle of a tensor. |
|
|
Returns an upper triangle of a tensor. |
|
|
Returns a new tensor of given shape and type, filled with zeros. |
|
|
Returns an array of zeros with the same shape and type as a given array. |
|
Array Operation
API Name |
Description |
Supported Platforms |
|
Appends values to the end of a tensor. |
|
|
Converts inputs to arrays with at least one dimension. |
|
|
Reshapes inputs as arrays with at least two dimensions. |
|
|
Reshapes inputs as arrays with at least three dimensions. |
|
|
Broadcasts any number of arrays against each other. |
|
|
Broadcasts an array to a new shape. |
|
|
Stacks 1-D tensors as columns into a 2-D tensor. |
|
|
Joins a sequence of tensors along an existing axis. |
|
|
Splits a tensor into multiple sub-tensors along the 3rd axis (depth). |
|
|
Stacks tensors in sequence depth wise (along the third axis). |
|
|
Expands the shape of a tensor. |
|
|
Reverses the order of elements in an array along the given axis. |
|
|
Flips the entries in each row in the left/right direction. |
|
|
Flips the entries in each column in the up/down direction. |
|
|
Splits a tensor into multiple sub-tensors horizontally (column-wise). |
|
|
Stacks tensors in sequence horizontally. |
|
|
Moves axes of an array to new positions. |
|
|
Returns a contiguous flattened tensor. |
|
|
Repeats elements of an array. |
|
|
Reshapes a tensor without changing its data. |
|
|
Rolls a tensor along given axes. |
|
|
Rolls the specified axis backwards, until it lies in the given position. |
|
|
Splits a tensor into multiple sub-tensors along the given axis. |
|
|
Removes single-dimensional entries from the shape of an tensor. |
|
|
Joins a sequence of arrays along a new axis. |
|
|
Interchanges two axes of a tensor. |
|
|
Takes elements from an array along an axis. |
|
|
Takes values from the input array by matching 1d index and data slices. |
|
|
Constructs an array by repeating a the number of times given by reps. |
|
|
Reverses or permutes the axes of a tensor; returns the modified tensor. |
|
|
Finds the unique elements of a tensor. |
|
|
Splits a tensor into multiple sub-tensors vertically (row-wise). |
|
|
Stacks tensors in sequence vertically. |
|
|
Returns elements chosen from x or y depending on condition. |
|
Logic
API Name |
Description |
Supported Platforms |
|
Returns the truth value of |
|
|
Returns the truth value of |
|
|
Returns the truth value of |
|
|
Tests element-wise for finiteness (not infinity or not Not a Number). |
|
|
Tests element-wise for positive or negative infinity. |
|
|
Tests element-wise for NaN and return result as a boolean array. |
|
|
Tests element-wise for negative infinity, returns result as bool array. |
|
|
Tests element-wise for positive infinity, returns result as bool array. |
|
|
Returns True if the type of element is a scalar type. |
|
|
Returns the truth value of |
|
|
Returns the truth value of |
|
|
Returns (x1 != x2) element-wise. |
|
Math
API Name |
Description |
Supported Platforms |
|
Calculates the absolute value element-wise. |
|
|
Adds arguments element-wise. |
|
|
Returns the maximum of an array or maximum along an axis. |
|
|
Returns the minimum of an array or minimum along an axis. |
|
|
Computes the weighted average along the specified axis. |
|
|
Clips (limits) the values in an array. |
|
|
Counts the number of non-zero values in the tensor x. |
|
|
Returns the cumulative sum of the elements along a given axis. |
|
|
Converts angles from degrees to radians. |
|
|
Extracts a diagonal or construct a diagonal array. |
|
|
Returns the indices to access the main diagonal of an array. |
|
|
Creates a two-dimensional array with the flattened input as a diagonal. |
|
|
Returns specified diagonals. |
|
|
Returns a true division of the inputs, element-wise. |
|
|
Returns the dot product of two arrays. |
|
|
Calculates the exponential of all elements in the input array. |
|
|
Calculates |
|
|
Rounds to nearest integer towards zero. |
|
|
First array elements raised to powers from second array, element-wise. |
|
|
Returns the floor of the input, element-wise. |
|
|
Returns the largest integer smaller or equal to the division of the inputs. |
|
|
Returns the element-wise remainder of division. |
|
|
Computes the Heaviside step function. |
|
|
Given the “legs” of a right triangle, returns its hypotenuse. |
|
|
Returns the inner product of two tensors. |
|
|
Returns the natural logarithm, element-wise. |
|
|
Returns the matrix product of two arrays. |
|
|
Returns the element-wise maximum of array elements. |
|
|
Computes the arithmetic mean along the specified axis. |
|
|
Element-wise minimum of tensor elements. |
|
|
Multiplies arguments element-wise. |
|
|
Numerical negative, element-wise. |
|
|
Computes the outer product of two vectors. |
|
|
Numerical positive, element-wise. |
|
|
First array elements raised to powers from second array, element-wise. |
|
|
Range of values (maximum - minimum) along an axis. |
|
|
Converts angles from radians to degrees. |
|
|
Returns the reciprocal of the argument, element-wise. |
|
|
Returns element-wise remainder of division. |
|
|
Returns the non-negative square-root of an array, element-wise. |
|
|
Returns the element-wise square of the input. |
|
|
Computes the standard deviation along the specified axis. |
|
|
Subtracts arguments, element-wise. |
|
|
Computes tensor dot product along specified axes. |
|
|
Returns the sum along diagonals of the array. |
|
|
Returns a true division of the inputs, element-wise. |
|
|
Returns the truncated value of the input, element-wise. |
|
|
Computes the variance along the specified axis. |
|