mindspore.ops.functional
functional算子是经过初始化后的Primitive,可以直接作为函数使用。functional算子的使用示例如下:
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]
神经网络层算子
激活函数
| functional | Description | 
|---|---|
| mindspore.ops.tanh | Refer to  | 
数学运算算子
逐元素运算
| 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算子
| 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  | 
比较算子
| 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  | 
线性代数算子
| 接口名 | 概述 | 支持平台 | 
| 计算两个数组的乘积。 | 
 | 
Tensor操作算子
Tensor创建
| functional | Description | 
|---|---|
| mindspore.ops.eye | Refer to  | 
| mindspore.ops.fill | Refer to  | 
| mindspore.ops.ones_like | Refer to  | 
| mindspore.ops.zeros_like | Refer to  | 
随机生成算子
| 接口名 | 概述 | 支持平台 | 
| 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操作
| 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  | 
| 接口名 | 概述 | 支持平台 | 
| 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. | 
 | 
类型转换
| 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操作算子
| 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  | 
调试算子
| functional | Description | 
|---|---|
| mindspore.ops.print_ | Refer to  | 
其他算子
| 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. | 
| 接口名 | 概述 | 支持平台 | 
| 根据给定的范围返回指定均匀间隔的数据。 | 
 | |
| 当输入的两个Tensor是批量数据时,对其进行批量点积操作。 | 
 | |
| 通过权重梯度总和的比率来裁剪多个Tensor的值。 | 
 | |
| 将输入Tensor值裁剪到指定的最小值和最大值之间。 | 
 | |
| 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'. | 
 | |
| 两个Tensor之间的点积。 | 
 | |
| 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. | 
 | |
| 在指定轴上复制输入Tensor的元素,类似 np.repeat 的功能。 | 
 | |
| 返回一个表示每个单元的前N个位置的掩码Tensor。 | 
 | |
| 在指定轴上对Tensor a 和 b 进行点乘操作。 | 
 | |
| 生成服从均匀分布的随机数。 | 
 | |
| Compute the vector-jacobian-product of the given network. | 
 |