mindspore/docs/api/api_python/mindspore.ops.functional.rst

567 lines
16 KiB
ReStructuredText
Raw Normal View History

2022-03-24 16:04:00 +08:00
mindspore.ops.functional
=============================
functional算子是经过初始化后的Primitive可以直接作为函数使用。functional算子的使用示例如下
.. code-block:: python
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]
2022-03-31 16:40:42 +08:00
神经网络层算子
----------------
2022-05-19 16:29:07 +08:00
神经网络
^^^^^^^^
.. mscnplatformautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
2022-05-19 17:55:27 +08:00
mindspore.ops.adaptive_avg_pool2d
2022-04-20 15:38:23 +08:00
mindspore.ops.adaptive_max_pool3d
2022-05-19 17:55:27 +08:00
mindspore.ops.avg_pool2d
2022-06-21 15:56:28 +08:00
mindspore.ops.deformable_conv2d
2022-06-26 17:24:43 +08:00
mindspore.ops.interpolate
2022-06-21 15:56:28 +08:00
mindspore.ops.kl_div
mindspore.ops.pad
2022-05-19 16:29:07 +08:00
mindspore.ops.pdist
2022-03-31 16:40:42 +08:00
激活函数
^^^^^^^^^^
.. mscnplatformautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
mindspore.ops.celu
mindspore.ops.fast_gelu
mindspore.ops.hardshrink
2022-06-09 10:51:38 +08:00
mindspore.ops.hardswish
2022-06-20 20:48:37 +08:00
mindspore.ops.log_softmax
2022-06-02 15:21:39 +08:00
mindspore.ops.padding
2022-06-17 17:29:28 +08:00
mindspore.ops.soft_shrink
mindspore.ops.tanh
2022-03-31 16:40:42 +08:00
损失函数
^^^^^^^^^^
.. mscnplatformautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
mindspore.ops.cross_entropy
mindspore.ops.nll_loss
2022-06-24 14:47:21 +08:00
mindspore.ops.smooth_l1_loss
2022-03-31 16:40:42 +08:00
数学运算算子
----------------
逐元素运算
^^^^^^^^^^^^^
.. mscnplatformautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
mindspore.ops.abs
mindspore.ops.acos
mindspore.ops.acosh
mindspore.ops.add
mindspore.ops.addn
mindspore.ops.asin
mindspore.ops.asinh
mindspore.ops.atan
mindspore.ops.atan2
mindspore.ops.atanh
mindspore.ops.bernoulli
mindspore.ops.bessel_i0
mindspore.ops.bessel_i0e
mindspore.ops.bessel_j0
mindspore.ops.bessel_j1
mindspore.ops.bessel_k0
mindspore.ops.bessel_k0e
mindspore.ops.bessel_y0
mindspore.ops.bessel_y1
mindspore.ops.bessel_i1
mindspore.ops.bessel_i1e
mindspore.ops.bessel_k1
mindspore.ops.bessel_k1e
mindspore.ops.bitwise_and
mindspore.ops.bitwise_or
mindspore.ops.bitwise_xor
2022-06-09 17:24:53 +08:00
mindspore.ops.ceil
mindspore.ops.cos
mindspore.ops.cosh
mindspore.ops.div
mindspore.ops.erf
mindspore.ops.erfc
mindspore.ops.exp
mindspore.ops.expm1
mindspore.ops.floor
mindspore.ops.floor_div
mindspore.ops.floor_mod
2022-05-18 16:03:20 +08:00
mindspore.ops.inplace_add
mindspore.ops.inplace_sub
mindspore.ops.inplace_update
2022-06-02 15:21:39 +08:00
mindspore.ops.inv
mindspore.ops.invert
2022-05-16 14:56:34 +08:00
mindspore.ops.lerp
mindspore.ops.log
mindspore.ops.logical_and
mindspore.ops.logical_not
mindspore.ops.logical_or
mindspore.ops.mul
mindspore.ops.neg
mindspore.ops.pow
mindspore.ops.round
mindspore.ops.sin
mindspore.ops.sinh
mindspore.ops.sub
mindspore.ops.svd
mindspore.ops.tan
2022-03-24 16:04:00 +08:00
.. list-table::
:widths: 50 50
:header-rows: 1
* - functional
- Description
* - mindspore.ops.absolute
- `absolute` will be deprecated in the future. Please use `mindspore.ops.abs` instead.
2022-03-24 16:04:00 +08:00
* - mindspore.ops.floordiv
- `floordiv` will be deprecated in the future. Please use `mindspore.ops.floor_div` instead.
2022-03-24 16:04:00 +08:00
* - mindspore.ops.floormod
- `floormod` will be deprecated in the future. Please use `mindspore.ops.floor_mod` instead.
2022-03-24 16:04:00 +08:00
* - mindspore.ops.neg_tensor
- `neg_tensor` will be deprecated in the future. Please use `mindspore.ops.neg` instead.
2022-03-24 16:04:00 +08:00
* - mindspore.ops.pows
- `pows` will be deprecated in the future. Please use `mindspore.ops.pow` instead.
2022-03-31 16:40:42 +08:00
* - mindspore.ops.sqrt
- Refer to :class:`mindspore.ops.Sqrt`.
* - mindspore.ops.square
- Refer to :class:`mindspore.ops.Square`.
* - mindspore.ops.tensor_add
- `tensor_add` will be deprecated in the future. Please use `mindspore.ops.add` instead.
2022-03-31 16:40:42 +08:00
* - mindspore.ops.tensor_div
- `tensor_div` will be deprecated in the future. Please use `mindspore.ops.div` instead.
2022-03-31 16:40:42 +08:00
* - mindspore.ops.tensor_exp
- `tensor_exp` will be deprecated in the future. Please use `mindspore.ops.exp` instead.
2022-03-31 16:40:42 +08:00
* - mindspore.ops.tensor_expm1
- `tensor_expm1` will be deprecated in the future. Please use `mindspore.ops.expm1` instead.
2022-03-31 16:40:42 +08:00
* - mindspore.ops.tensor_floordiv
- `tensor_floordiv` will be deprecated in the future. Please use `mindspore.ops.floor_div` instead.
2022-03-31 16:40:42 +08:00
* - mindspore.ops.tensor_mod
- `tensor_mod` will be deprecated in the future. Please use `mindspore.ops.floor_mod` instead.
2022-03-31 16:40:42 +08:00
* - mindspore.ops.tensor_mul
- `tensor_mul` will be deprecated in the future. Please use `mindspore.ops.mul` instead.
2022-03-31 16:40:42 +08:00
* - mindspore.ops.tensor_pow
- `tensor_pow` will be deprecated in the future. Please use `mindspore.ops.pow` instead.
2022-03-31 16:40:42 +08:00
* - mindspore.ops.tensor_sub
- `tensor_sub` will be deprecated in the future. Please use `mindspore.ops.sub` instead.
2022-03-31 16:40:42 +08:00
Reduction算子
^^^^^^^^^^^^^
2022-05-26 16:49:00 +08:00
.. mscnplatformautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
mindspore.ops.logsumexp
mindspore.ops.norm
2022-05-26 16:49:00 +08:00
2022-03-31 16:40:42 +08:00
.. list-table::
:widths: 50 50
:header-rows: 1
* - functional
- Description
2022-03-24 16:04:00 +08:00
* - mindspore.ops.reduce_max
- Refer to :class:`mindspore.ops.ReduceMax`.
* - mindspore.ops.reduce_mean
- Refer to :class:`mindspore.ops.ReduceMean`.
* - mindspore.ops.reduce_min
- Refer to :class:`mindspore.ops.ReduceMin`.
* - mindspore.ops.reduce_prod
- Refer to :class:`mindspore.ops.ReduceProd`.
* - mindspore.ops.reduce_sum
- Refer to :class:`mindspore.ops.ReduceSum`.
2022-03-31 16:40:42 +08:00
比较算子
^^^^^^^^^^^^^
.. mscnplatformautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
mindspore.ops.argmin
2022-06-28 17:19:46 +08:00
mindspore.ops.cummax
mindspore.ops.cummin
mindspore.ops.equal
mindspore.ops.ge
mindspore.ops.gt
2022-05-16 18:50:05 +08:00
mindspore.ops.intopk
2022-06-11 15:19:28 +08:00
mindspore.ops.isclose
mindspore.ops.isfinite
mindspore.ops.isnan
mindspore.ops.le
mindspore.ops.less
mindspore.ops.maximum
mindspore.ops.minimum
mindspore.ops.ne
mindspore.ops.same_type_shape
2022-03-31 16:40:42 +08:00
.. list-table::
:widths: 50 50
:header-rows: 1
* - functional
- Description
* - mindspore.ops.check_bprop
- Refer to :class:`mindspore.ops.CheckBprop`.
* - mindspore.ops.isinstance\_
2022-04-24 11:28:35 +08:00
- Refer to :class:`mindspore.ops.IsInstance`.
2022-03-31 16:40:42 +08:00
* - mindspore.ops.issubclass\_
- Refer to :class:`mindspore.ops.IsSubClass`.
* - mindspore.ops.not_equal
- `not_equal` will be deprecated in the future. Please use `mindspore.ops.ne` instead.
2022-03-31 16:40:42 +08:00
* - mindspore.ops.tensor_ge
- `tensor_ge` will be deprecated in the future. Please use `mindspore.ops.ge` instead.
2022-03-31 16:40:42 +08:00
* - mindspore.ops.tensor_gt
- `tensor_gt` will be deprecated in the future. Please use `mindspore.ops.gt` instead.
2022-03-31 16:40:42 +08:00
* - mindspore.ops.tensor_le
- `tensor_le` will be deprecated in the future. Please use `mindspore.ops.le` instead.
2022-03-31 16:40:42 +08:00
* - mindspore.ops.tensor_lt
- `tensor_lt` will be deprecated in the future. Please use `mindspore.ops.less` instead.
2022-03-31 16:40:42 +08:00
线性代数算子
^^^^^^^^^^^^^
.. mscnplatformautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
2022-04-22 14:56:44 +08:00
mindspore.ops.matmul
2022-06-21 09:44:57 +08:00
mindspore.ops.matrix_solve
2022-04-22 14:56:44 +08:00
mindspore.ops.cdist
mindspore.ops.ger
2022-06-01 15:04:05 +08:00
mindspore.ops.renorm
2022-03-31 16:40:42 +08:00
Tensor操作算子
----------------
Tensor创建
^^^^^^^^^^^^^
.. mscnplatformautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
2022-03-31 16:40:42 +08:00
mindspore.ops.eye
mindspore.ops.fill
2022-05-13 11:00:59 +08:00
mindspore.ops.fills
2022-06-20 19:21:03 +08:00
mindspore.ops.linspace
mindspore.ops.ones
mindspore.ops.ones_like
mindspore.ops.zeros_like
2022-03-31 16:40:42 +08:00
随机生成算子
^^^^^^^^^^^^^^^^
.. mscnplatformautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
mindspore.ops.gamma
mindspore.ops.multinomial
mindspore.ops.poisson
mindspore.ops.standard_laplace
mindspore.ops.uniform
2022-03-31 16:40:42 +08:00
Array操作
^^^^^^^^^^^^^^^^
.. mscnplatformautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
2022-05-28 12:01:53 +08:00
mindspore.ops.adaptive_max_pool2d
2022-06-09 11:19:40 +08:00
mindspore.ops.batch_to_space_nd
mindspore.ops.broadcast_to
mindspore.ops.col2im
mindspore.ops.concat
mindspore.ops.diag
mindspore.ops.dyn_shape
mindspore.ops.expand_dims
2022-06-09 11:19:40 +08:00
mindspore.ops.flatten
mindspore.ops.gather
mindspore.ops.gather_d
mindspore.ops.gather_elements
mindspore.ops.gather_nd
2022-06-09 11:19:40 +08:00
mindspore.ops.gumbel_softmax
2022-06-04 15:32:43 +08:00
mindspore.ops.masked_fill
2022-05-20 14:48:06 +08:00
mindspore.ops.masked_select
2022-06-02 15:21:39 +08:00
mindspore.ops.matrix_band_part
2022-05-26 09:17:20 +08:00
mindspore.ops.matrix_diag
2022-06-20 20:36:25 +08:00
mindspore.ops.matrix_diag_part
mindspore.ops.meshgrid
mindspore.ops.affine_grid
mindspore.ops.nonzero
2022-05-18 10:32:13 +08:00
mindspore.ops.one_hot
2022-06-02 15:21:39 +08:00
mindspore.ops.padding
2022-05-12 15:13:58 +08:00
mindspore.ops.range
mindspore.ops.rank
mindspore.ops.reshape
mindspore.ops.scatter_nd
mindspore.ops.select
mindspore.ops.shape
mindspore.ops.size
mindspore.ops.slice
2022-05-26 11:02:27 +08:00
mindspore.ops.space_to_batch_nd
2022-06-17 14:28:33 +08:00
mindspore.ops.split
mindspore.ops.tensor_scatter_add
mindspore.ops.tensor_scatter_min
2022-05-05 18:50:43 +08:00
mindspore.ops.tensor_scatter_div
2022-05-26 11:02:27 +08:00
mindspore.ops.tensor_scatter_mul
mindspore.ops.tensor_scatter_sub
2022-06-26 16:40:45 +08:00
mindspore.ops.tensor_scatter_elements
mindspore.ops.tile
mindspore.ops.transpose
2022-06-20 19:22:43 +08:00
mindspore.ops.unsorted_segment_min
mindspore.ops.unsorted_segment_max
mindspore.ops.unsorted_segment_prod
mindspore.ops.unique
2022-05-17 11:37:00 +08:00
mindspore.ops.unique_consecutive
2022-06-16 16:21:05 +08:00
mindspore.ops.unique_with_pad
2022-03-31 16:40:42 +08:00
.. list-table::
:widths: 50 50
:header-rows: 1
* - functional
- Description
* - mindspore.ops.cast
- Refer to :class:`mindspore.ops.Cast`.
* - mindspore.ops.cumprod
- Refer to :class:`mindspore.ops.CumProd`.
* - mindspore.ops.cumsum
- Refer to :class:`mindspore.ops.CumSum`.
* - mindspore.ops.dtype
- Refer to :class:`mindspore.ops.DType`.
* - mindspore.ops.sort
- Refer to :class:`mindspore.ops.Sort`.
* - mindspore.ops.squeeze
- Refer to :class:`mindspore.ops.Squeeze`.
* - mindspore.ops.stack
- Refer to :class:`mindspore.ops.Stack`.
* - mindspore.ops.strided_slice
- Refer to :class:`mindspore.ops.StridedSlice`.
* - mindspore.ops.tensor_scatter_update
- Refer to :class:`mindspore.ops.TensorScatterUpdate`.
* - mindspore.ops.tensor_slice
- `tensor_slice` will be deprecated in the future. Please use `mindspore.ops.slice` instead.
类型转换
^^^^^^^^^^^^^^^^
2022-03-31 16:40:42 +08:00
.. mscnplatformautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
mindspore.ops.scalar_cast
mindspore.ops.scalar_to_array
mindspore.ops.scalar_to_tensor
mindspore.ops.tuple_to_array
2022-03-31 16:40:42 +08:00
2022-06-15 15:10:38 +08:00
稀疏算子
^^^^^^^^^^^^^^^^
.. mscnplatformautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
mindspore.ops.dense_to_sparse_coo
mindspore.ops.dense_to_sparse_csr
2022-04-16 09:53:22 +08:00
Parameter操作算子
--------------------
.. mscnplatformautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
mindspore.ops.assign
mindspore.ops.assign_add
mindspore.ops.assign_sub
mindspore.ops.index_add
mindspore.ops.scatter_add
2022-05-25 15:38:29 +08:00
mindspore.ops.scatter_div
2022-04-29 11:37:17 +08:00
mindspore.ops.scatter_min
mindspore.ops.scatter_max
mindspore.ops.scatter_nd_add
mindspore.ops.scatter_nd_div
mindspore.ops.scatter_nd_max
mindspore.ops.scatter_nd_min
mindspore.ops.scatter_nd_mul
mindspore.ops.scatter_nd_sub
mindspore.ops.scatter_update
2022-04-16 09:53:22 +08:00
.. list-table::
:widths: 50 50
:header-rows: 1
* - functional
- Description
* - mindspore.ops.scatter_nd_update
- Refer to :class:`mindspore.ops.ScatterNdUpdate`.
调试算子
----------------
.. list-table::
:widths: 50 50
:header-rows: 1
* - functional
- Description
* - mindspore.ops.print\_
- Refer to :class:`mindspore.ops.Print`.
2022-03-31 16:40:42 +08:00
其他算子
----------------
.. list-table::
:widths: 50 50
:header-rows: 1
* - 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 :class:`mindspore.ops.Depend`.
* - 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 :class:`mindspore.ops.Partial`.
* - mindspore.ops.scalar_add
- Get the sum of two numbers. (Usage is the same as "+" in Python)
2022-03-24 16:04:00 +08:00
* - 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
2022-04-28 16:31:27 +08:00
- Disable update during back propagation. (`stop_gradient <https://www.mindspore.cn/tutorials/en/master/beginner/autograd.html#stopping-gradient-calculation>`_)
2022-03-24 16:04:00 +08:00
* - mindspore.ops.string_concat
- Concatenate two strings.
* - mindspore.ops.string_eq
- Determine if two strings are equal.
* - mindspore.ops.typeof
- Get type of object.
.. mscnplatformautosummary::
:toctree: ops
:nosignatures:
:template: classtemplate.rst
mindspore.ops.arange
mindspore.ops.batch_dot
mindspore.ops.clip_by_global_norm
mindspore.ops.clip_by_value
mindspore.ops.core
mindspore.ops.count_nonzero
2022-05-11 10:39:52 +08:00
mindspore.ops.derivative
2022-03-24 16:04:00 +08:00
mindspore.ops.dot
mindspore.ops.grad
2022-05-11 10:39:52 +08:00
mindspore.ops.jet
2022-03-24 16:04:00 +08:00
mindspore.ops.jvp
mindspore.ops.laplace
mindspore.ops.narrow
mindspore.ops.normal
mindspore.ops.repeat_elements
mindspore.ops.sequence_mask
mindspore.ops.tensor_dot
mindspore.ops.uniform
2022-03-26 16:58:33 +08:00
mindspore.ops.vjp
2022-05-26 16:21:12 +08:00
mindspore.ops.vmap