mindspore.ops.functional
The functional operators are initialized Primitives and can be used directly as functions. An example of the use of the functional operator is as follows:
from mindspore import Tensor, ops
from mindspore import dtype as mstype
input_x = Tensor(-1, mstype.int32)
input_dict = {'x':1, 'y':2}
result_abs = ops.absolute(input_x)
print(result_abs)
result_in_dict = ops.in_dict('x', input_dict)
print(result_in_dict)
result_not_in_dict = ops.not_in_dict('x', input_dict)
print(result_not_in_dict)
result_isconstant = ops.isconstant(input_x)
print(result_isconstant)
result_typeof = ops.typeof(input_x)
print(result_typeof)
# outputs:
# 1
# True
# False
# True
# Tensor[Int32]
Neural Network Layer Operators
Activation Functions
functional |
Description |
---|---|
mindspore.ops.tanh |
Refer to |
Mathematical Operators
Element-by-Element Operations
functional |
Description |
---|---|
mindspore.ops.absolute |
Refer to |
mindspore.ops.acos |
Refer to |
mindspore.ops.acosh |
Refer to |
mindspore.ops.add |
Refer to |
mindspore.ops.addn |
Refer to |
mindspore.ops.asin |
Refer to |
mindspore.ops.asinh |
Refer to |
mindspore.ops.atan |
Refer to |
mindspore.ops.atan2 |
Refer to |
mindspore.ops.atanh |
Refer to |
mindspore.ops.bitwise_and |
Refer to |
mindspore.ops.bitwise_or |
Refer to |
mindspore.ops.bitwise_xor |
Refer to |
mindspore.ops.cos |
Refer to |
mindspore.ops.cosh |
Refer to |
mindspore.ops.div |
Refer to |
mindspore.ops.erf |
Refer to |
mindspore.ops.erfc |
Refer to |
mindspore.ops.exp |
Refer to |
mindspore.ops.floor |
Refer to |
mindspore.ops.floordiv |
Refer to |
mindspore.ops.floormod |
Refer to |
mindspore.ops.log |
Refer to |
mindspore.ops.logical_and |
Refer to |
mindspore.ops.logical_not |
Refer to |
mindspore.ops.logical_or |
Refer to |
mindspore.ops.invert |
Refer to |
mindspore.ops.mul |
Refer to |
mindspore.ops.neg_tensor |
Refer to |
mindspore.ops.pows |
Refer to |
mindspore.ops.sin |
Refer to |
mindspore.ops.sinh |
Refer to |
mindspore.ops.sqrt |
Refer to |
mindspore.ops.square |
Refer to |
mindspore.ops.sub |
Refer to |
mindspore.ops.tan |
Refer to |
mindspore.ops.tensor_add |
Refer to |
mindspore.ops.tensor_div |
Refer to |
mindspore.ops.tensor_exp |
Refer to |
mindspore.ops.tensor_expm1 |
Refer to |
mindspore.ops.tensor_floordiv |
Refer to |
mindspore.ops.tensor_mod |
Refer to |
mindspore.ops.tensor_mul |
Refer to |
mindspore.ops.tensor_pow |
Refer to |
mindspore.ops.tensor_sub |
Refer to |
Reduction Operators
functional |
Description |
---|---|
mindspore.ops.reduce_max |
Refer to |
mindspore.ops.reduce_mean |
Refer to |
mindspore.ops.reduce_min |
Refer to |
mindspore.ops.reduce_prod |
Refer to |
mindspore.ops.reduce_sum |
Refer to |
Comparison operators
functional |
Description |
---|---|
mindspore.ops.check_bprop |
Refer to |
mindspore.ops.equal |
Refer to |
mindspore.ops.ge |
Refer to |
mindspore.ops.gt |
Refer to |
mindspore.ops.le |
Refer to |
mindspore.ops.less |
Refer to |
mindspore.ops.isfinite |
Refer to |
mindspore.ops.isinstance_ |
Refer to |
mindspore.ops.isnan |
Refer to |
mindspore.ops.issubclass_ |
Refer to |
mindspore.ops.maximum |
Refer to |
mindspore.ops.minimum |
Refer to |
mindspore.ops.not_equal |
Refer to |
mindspore.ops.same_type_shape |
Refer to |
mindspore.ops.tensor_ge |
Refer to |
mindspore.ops.tensor_gt |
Refer to |
mindspore.ops.tensor_le |
Refer to |
mindspore.ops.tensor_lt |
Refer to |
Linear Algebraic Operators
API Name |
Description |
Supported Platforms |
Returns the matrix product of two arrays. |
|
Tensor Operation Operators
Tensor Building
functional |
Description |
---|---|
mindspore.ops.eye |
Refer to |
mindspore.ops.fill |
Refer to |
mindspore.ops.ones_like |
Refer to |
mindspore.ops.zeros_like |
Refer to |
Randomly Generating Operators
API Name |
Description |
Supported Platforms |
Generates random numbers according to the Gamma random number distribution. |
|
|
Returns a tensor sampled from the multinomial probability distribution located in the corresponding row of the input tensor. |
|
|
Generates random numbers according to the Poisson random number distribution. |
|
Array Operation
functional |
Description |
---|---|
mindspore.ops.cast |
Refer to |
mindspore.ops.cumprod |
Refer to |
mindspore.ops.cumsum |
Refer to |
mindspore.ops.dtype |
Refer to |
mindspore.ops.expand_dims |
Refer to |
mindspore.ops.gather |
Refer to |
mindspore.ops.gather_d |
Refer to |
mindspore.ops.gather_nd |
Refer to |
mindspore.ops.rank |
Refer to |
mindspore.ops.reshape |
Refer to |
mindspore.ops.scatter_nd |
Refer to |
mindspore.ops.shape |
Refer to |
mindspore.ops.size |
Refer to |
mindspore.ops.sort |
Refer to |
mindspore.ops.squeeze |
Refer to |
mindspore.ops.stack |
Refer to |
mindspore.ops.strided_slice |
Refer to |
mindspore.ops.tensor_scatter_add |
Refer to |
mindspore.ops.tensor_scatter_update |
Refer to |
mindspore.ops.tensor_slice |
Refer to |
mindspore.ops.tile |
Refer to |
mindspore.ops.transpose |
Refer to |
API Name |
Description |
Supported Platforms |
Returns the selected elements, either from input \(x\) or input \(y\), depending on the condition cond. |
|
|
Returns the unique elements of input tensor and also return a tensor containing the index of each value of input tensor corresponding to the output unique tensor. |
|
Type Conversion
functional |
Description |
---|---|
mindspore.ops.scalar_cast |
Refer to |
mindspore.ops.scalar_to_array |
Refer to |
mindspore.ops.scalar_to_tensor |
Refer to |
mindspore.ops.tuple_to_array |
Refer to |
Parameter Operation Oprators
functional |
Description |
---|---|
mindspore.ops.assign |
Refer to |
mindspore.ops.assign_add |
Refer to |
mindspore.ops.assign_sub |
Refer to |
mindspore.ops.scatter_nd_update |
Refer to |
mindspore.ops.scatter_update |
Refer to |
Debugging Operators
functional |
Description |
---|---|
mindspore.ops.print_ |
Refer to |
Other Operators
functional |
Description |
---|---|
mindspore.ops.bool_and |
Calculate the result of logical AND operation. (Usage is the same as “and” in Python) |
mindspore.ops.bool_eq |
Determine whether the Boolean values are equal. (Usage is the same as “==” in Python) |
mindspore.ops.bool_not |
Calculate the result of logical NOT operation. (Usage is the same as “not” in Python) |
mindspore.ops.bool_or |
Calculate the result of logical OR operation. (Usage is the same as “or” in Python) |
mindspore.ops.depend |
Refer to |
mindspore.ops.in_dict |
Determine if a str in dict. |
mindspore.ops.is_not |
Determine whether the input is not the same as the other one. (Usage is the same as “is not” in Python) |
mindspore.ops.is_ |
Determine whether the input is the same as the other one. (Usage is the same as “is” in Python) |
mindspore.ops.isconstant |
Determine whether the object is constant. |
mindspore.ops.not_in_dict |
Determine whether the object is not in the dict. |
mindspore.ops.partial |
Refer to |
mindspore.ops.scalar_add |
Get the sum of two numbers. (Usage is the same as “+” in Python) |
mindspore.ops.scalar_div |
Get the quotient of dividing the first input number by the second input number. (Usage is the same as “/” in Python) |
mindspore.ops.scalar_eq |
Determine whether two numbers are equal. (Usage is the same as “==” in Python) |
mindspore.ops.scalar_floordiv |
Divide the first input number by the second input number and round down to the closest integer. (Usage is the same as “//” in Python) |
mindspore.ops.scalar_ge |
Determine whether the number is greater than or equal to another number. (Usage is the same as “>=” in Python) |
mindspore.ops.scalar_gt |
Determine whether the number is greater than another number. (Usage is the same as “>” in Python) |
mindspore.ops.scalar_le |
Determine whether the number is less than or equal to another number. (Usage is the same as “<=” in Python) |
mindspore.ops.scalar_log |
Get the natural logarithm of the input number. |
mindspore.ops.scalar_lt |
Determine whether the number is less than another number. (Usage is the same as “<” in Python) |
mindspore.ops.scalar_mod |
Get the remainder of dividing the first input number by the second input number. (Usage is the same as “%” in Python) |
mindspore.ops.scalar_mul |
Get the product of the input two numbers. (Usage is the same as “*” in Python) |
mindspore.ops.scalar_ne |
Determine whether two numbers are not equal. (Usage is the same as “!=” in Python) |
mindspore.ops.scalar_pow |
Compute a number to the power of the second input number. |
mindspore.ops.scalar_sub |
Subtract the second input number from the first input number. (Usage is the same as “-” in Python) |
mindspore.ops.scalar_uadd |
Get the positive value of the input number. |
mindspore.ops.scalar_usub |
Get the negative value of the input number. |
mindspore.ops.shape_mul |
The input of shape_mul must be shape multiply elements in tuple(shape). |
mindspore.ops.stop_gradient |
Disable update during back propagation. (stop_gradient) |
mindspore.ops.string_concat |
Concatenate two strings. |
mindspore.ops.string_eq |
Determine if two strings are equal. |
mindspore.ops.typeof |
Get type of object. |
API Name |
Description |
Supported Platforms |
Returns evenly spaced values within a given interval. |
|
|
Computation of batch dot product between samples in two tensors containing batch dims. |
|
|
Clips tensor values by the ratio of the sum of their norms. |
|
|
Clips tensor values to a specified min and max. |
|
|
A decorator that adds a flag to the function. |
|
|
Count number of nonzero elements across axis of input tensor |
|
|
Computation of the cumulative minimum of elements of 'x' in the dimension axis, and the index location of each maximum value found in the dimension 'axis'. |
|
|
Computation a dot product between samples in two tensors. |
|
|
A wrapper function to generate the gradient function for the input function. |
|
|
Compute the jacobian-vector-product of the given network. |
|
|
Generates random numbers according to the Laplace random number distribution. |
|
|
Returns a narrowed tensor from input tensor. |
|
|
Generates random numbers according to the Normal (or Gaussian) random number distribution. |
|
|
Repeat elements of a tensor along an axis, like np.repeat . |
|
|
Returns a mask tensor representing the first N positions of each cell. |
|
|
Computation of Tensor contraction on arbitrary axes between tensors a and b. |
|
|
Generates random numbers according to the Uniform random number distribution. |
|
|
Compute the vector-jacobian-product of the given network. |
|