forked from mindspore-Ecosystem/mindspore
optimize the documentation of english API of Add,AddN,Div,Eps, etc
This commit is contained in:
parent
5e572f9b51
commit
df729c2f28
|
@ -11,7 +11,7 @@ mindspore.ops.Erf
|
|||
|
||||
**输入:**
|
||||
|
||||
- **x** (Tensor) - 高斯误差函数的输入Tensor。数据类型必须为float16或float32。任意维度小于8的Tensor。
|
||||
- **x** (Tensor) - 高斯误差函数的输入Tensor。维度必须小于8,数据类型必须为float16或float32。
|
||||
|
||||
**输出:**
|
||||
|
||||
|
|
|
@ -450,7 +450,7 @@ class IsInstance(PrimitiveWithInfer):
|
|||
|
||||
class Reshape(PrimitiveWithInfer):
|
||||
"""
|
||||
Reshapes the input tensor with the same values based on a given shape tuple.
|
||||
Rearranges the input Tensor based on the given shape.
|
||||
|
||||
The 'input_shape' can only have one -1 at most, in which case it’s inferred from the remaining dimensions and
|
||||
the number of elements in the input.
|
||||
|
@ -1220,12 +1220,12 @@ class TruncatedNormal(PrimitiveWithInfer):
|
|||
|
||||
class Size(PrimitiveWithInfer):
|
||||
r"""
|
||||
Returns the size of a Tensor.
|
||||
|
||||
Returns an int scalar representing the elements' size of input, the total number of elements in the tensor.
|
||||
Returns a Scalar of type int that represents the size of the input Tensor and the total number of elements in the
|
||||
Tensor.
|
||||
|
||||
Inputs:
|
||||
- **input_x** (Tensor) - The shape of tensor is :math:`(x_1, x_2, ..., x_R)`. The data type is Number.
|
||||
- **input_x** (Tensor) - Input parameters, the shape of tensor is :math:`(x_1, x_2, ..., x_R)`. The data type is
|
||||
`number <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_.
|
||||
|
||||
Outputs:
|
||||
int. A scalar representing the elements' size of `input_x`, tensor is the number of elements
|
||||
|
@ -1397,13 +1397,10 @@ class Zeros(Primitive):
|
|||
|
||||
class OnesLike(Primitive):
|
||||
"""
|
||||
Creates a new tensor. The values of all elements are 1.
|
||||
|
||||
Returns a tensor of ones with the same shape and type as the input.
|
||||
Returns a Tensor with a value of 1 and its shape and data type is the same as the input.
|
||||
|
||||
Inputs:
|
||||
- **input_x** (Tensor) - Input tensor.
|
||||
The shape is :math:`(N,*)` where :math:`*` means, any number of additional dimensions.
|
||||
- **input_x** (Tensor) - Tensor of any dimension.
|
||||
|
||||
Outputs:
|
||||
Tensor, has the same shape and type as `input_x` but filled with ones.
|
||||
|
@ -1430,13 +1427,10 @@ class OnesLike(Primitive):
|
|||
|
||||
class ZerosLike(Primitive):
|
||||
"""
|
||||
Creates a new tensor. All elements value are 0.
|
||||
|
||||
Returns a tensor of zeros with the same shape and data type as the input tensor.
|
||||
Returns a Tensor with a value of 0 and its shape and data type is the same as the input.
|
||||
|
||||
Inputs:
|
||||
- **input_x** (Tensor) - Input tensor. The data type is int32, int64, float16 or float32.
|
||||
The shape is :math:`(N,*)` where :math:`*` means, any number of additional dimensions.
|
||||
- **input_x** (Tensor) - Input Tensor of any dimension. The data type is int32, int64, float16 or float32.
|
||||
|
||||
Outputs:
|
||||
Tensor, has the same shape and data type as `input_x` but filled with zeros.
|
||||
|
@ -1935,35 +1929,34 @@ class ArgMinWithValue(PrimitiveWithInfer):
|
|||
|
||||
class Tile(PrimitiveWithInfer):
|
||||
r"""
|
||||
Replicates a tensor with given multiples times.
|
||||
Replicates an input tensor with given multiples times.
|
||||
|
||||
Creates a new tensor by replicating `input_x` `multiples` times. The i'th dimension of
|
||||
output tensor has `input_x.shape(i) * multiples[i]` elements, and the values of `input_x`
|
||||
output tensor has `input_x.shape[i] * multiples[i]` elements, and the values of `input_x`
|
||||
are replicated `multiples[i]` times along the i'th dimension.
|
||||
|
||||
Note:
|
||||
The length of `multiples` must be greater or equal to the length of dimension in `input_x`.
|
||||
|
||||
Inputs:
|
||||
- **input_x** (Tensor) - 1-D or higher Tensor. Set the shape of input tensor as
|
||||
- **input_x** (Tensor) - 1-D or higher dimensional Tensor. Set the shape of input tensor as
|
||||
:math:`(x_1, x_2, ..., x_S)`.
|
||||
|
||||
- **multiples** (tuple[int]) - The input tuple is constructed by multiple
|
||||
integers, i.e., :math:`(y_1, y_2, ..., y_S)`. The length of `multiples`
|
||||
cannot be smaller than the length of the shape of `input_x`.
|
||||
- **multiples** (tuple[int]) - The parameter that specifies the number of replications,
|
||||
the parameter type is tuple, and the data type is int, i.e., :math:`(y_1, y_2, ..., y_S)`.
|
||||
The length of `multiples` cannot be smaller than the length of the shape of `input_x`.
|
||||
Only constant value is allowed.
|
||||
|
||||
Outputs:
|
||||
Tensor, has the same data type as the `input_x`.
|
||||
Tensor, has the same data type as the `input_x`. Suppose the length of `multiples` is `d`,
|
||||
the dimension of `input_x` is `input_x.dim`, and the shape of `input_x` is :math:`(x_1, x_2, ..., x_S)`.
|
||||
|
||||
- If the length of `multiples` is the same as the length of shape of `input_x`,
|
||||
then the shape of their corresponding positions can be multiplied, and
|
||||
- If `input_x.dim = d`, then the shape of their corresponding positions can be multiplied, and
|
||||
the shape of Outputs is :math:`(x_1*y_1, x_2*y_2, ..., x_S*y_R)`.
|
||||
- If the length of `multiples` is larger than the length of shape of `input_x`,
|
||||
fill in multiple 1 in the length of the shape of `input_x` until their lengths are consistent.
|
||||
Such as set the shape of `input_x` as :math:`(1, ..., x_1, x_2, ..., x_S)`,
|
||||
then the shape of their corresponding positions can be multiplied, and
|
||||
the shape of Outputs is :math:`(1*y_1, ..., x_S*y_R)`.
|
||||
- If `input_x.dim < d`, fill in multiple 1 in the length of the shape of `input_x` until their
|
||||
lengths are consistent. Such as set the shape of `input_x` as :math:`(1, ..., x_1, x_2, ..., x_S)`,
|
||||
then the shape of their corresponding positions can be multiplied, and the shape of Outputs is
|
||||
:math:`(1*y_1, ..., x_S*y_R)`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `multiples` is not a tuple or its elements are not all int.
|
||||
|
|
|
@ -182,29 +182,34 @@ class Add(_MathBinaryOp):
|
|||
r"""
|
||||
Adds two input tensors element-wise.
|
||||
|
||||
Inputs of `x` and `y` comply with the implicit type conversion rules to make the data types consistent.
|
||||
The inputs must be two tensors or one tensor and one scalar.
|
||||
When the inputs are two tensors,
|
||||
dtypes of them cannot be bool at the same time, and the shapes of them could be broadcast.
|
||||
When the inputs are one tensor and one scalar,
|
||||
the scalar could only be a constant.
|
||||
|
||||
.. math::
|
||||
|
||||
out_{i} = x_{i} + y_{i}
|
||||
|
||||
.. note::
|
||||
- Inputs of `x` and `y` comply with the
|
||||
`implicit type conversion rules <https://www.mindspore.cn/docs/note/en/master/operator_list_implicit.html>`_
|
||||
to make the data types consistent.
|
||||
- The inputs must be two tensors or one tensor and one scalar.
|
||||
- When the inputs are two tensors,
|
||||
dtypes of them cannot be bool at the same time, and the shapes of them can be broadcast.
|
||||
- When the inputs are one tensor and one scalar, the scalar could only be a constant.
|
||||
|
||||
Inputs:
|
||||
- **x** (Union[Tensor, Number, bool]) - The first input is a number, or a bool,
|
||||
or a tensor whose data type is number or bool.
|
||||
- **y** (Union[Tensor, Number, bool]) - The second input is a number, or a bool when the first input
|
||||
is a tensor, or a tensor whose data type is number or bool.
|
||||
- **x** (Union[Tensor, number.Number, bool]) - The first input is a number.Number or
|
||||
a bool or a tensor whose data type is
|
||||
`number <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_ or
|
||||
`bool_ <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_.
|
||||
- **y** (Union[Tensor, number.Number, bool]) - The second input, when the first input is a Tensor,
|
||||
the second input should be a number.Number or bool value, or a Tensor whose data type is number or bool_.
|
||||
When the first input is Scalar, the second input must be a Tensor whose data type is number or bool_.
|
||||
|
||||
Outputs:
|
||||
Tensor, the shape is the same as the one after broadcasting,
|
||||
Tensor, the shape is the same as the one of the input `x` , `y` after broadcasting,
|
||||
and the data type is the one with higher precision or higher digits among the two inputs.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` and `y` is not one of the following: Tensor, Number, bool.
|
||||
TypeError: If `x` and `y` is not one of the following: Tensor, number.Number, bool.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
@ -1534,14 +1539,16 @@ class AddN(Primitive):
|
|||
All input tensors must have the same shape.
|
||||
|
||||
Inputs:
|
||||
- **x** (Union(tuple[Tensor], list[Tensor])) - The input tuple or list
|
||||
is made up of multiple tensors whose dtype is number to be added together.
|
||||
- **x** (Union(tuple[Tensor], list[Tensor])) - A tuple or list composed of Tensor, the data type is
|
||||
`bool_ <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_ or
|
||||
`number <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_ .
|
||||
|
||||
Outputs:
|
||||
Tensor, has the same shape and dtype as each entry of the `x`.
|
||||
Tensor, has the same shape and dtype as each Tensor of `x`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` is neither tuple nor list.
|
||||
ValueError: If there are Tensors with different shapes in `x`.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
@ -1828,29 +1835,34 @@ class Sub(_MathBinaryOp):
|
|||
"""
|
||||
Subtracts the second input tensor from the first input tensor element-wise.
|
||||
|
||||
Inputs of `x` and `y` comply with the implicit type conversion rules to make the data types consistent.
|
||||
The inputs must be two tensors or one tensor and one scalar.
|
||||
When the inputs are two tensors,
|
||||
dtypes of them cannot be bool at the same time, and the shapes of them could be broadcast.
|
||||
When the inputs are one tensor and one scalar,
|
||||
the scalar could only be a constant.
|
||||
|
||||
.. math::
|
||||
|
||||
out_{i} = x_{i} - y_{i}
|
||||
|
||||
.. note::
|
||||
- Inputs of `x` and `y` comply with the
|
||||
`implicit type conversion rules <https://www.mindspore.cn/docs/note/en/master/operator_list_implicit.html>`_
|
||||
to make the data types consistent.
|
||||
- The inputs must be two tensors or one tensor and one scalar.
|
||||
- When the inputs are two tensors,
|
||||
dtypes of them cannot be bool at the same time, and the shapes of them can be broadcast.
|
||||
- When the inputs are one tensor and one scalar, the scalar could only be a constant.
|
||||
|
||||
Inputs:
|
||||
- **x** (Union[Tensor, Number, bool]) - The first input is a number, or a bool,
|
||||
or a tensor whose data type is number or bool.
|
||||
- **y** (Union[Tensor, Number, bool]) - The second input is a number, or a bool when the first input
|
||||
is a tensor, or a tensor whose data type is number or bool.
|
||||
- **x** (Union[Tensor, number.Number, bool]) - The first input is a number.Number or
|
||||
a bool or a tensor whose data type is
|
||||
`number <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_ or
|
||||
`bool_ <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_.
|
||||
- **y** (Union[Tensor, number.Number, bool]) - The second input, when the first input is a Tensor,
|
||||
the second input should be a number.Number or bool value, or a Tensor whose data type is number or bool_.
|
||||
When the first input is Scalar, the second input must be a Tensor whose data type is number or bool_.
|
||||
|
||||
Outputs:
|
||||
Tensor, the shape is the same as the one after broadcasting,
|
||||
and the data type is the one with higher precision or higher digits among the two inputs.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` and `y` is not a Number or a bool or a Tensor.
|
||||
TypeError: If `x` and `y` is not a number.Number or a bool or a Tensor.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
@ -1878,29 +1890,33 @@ class Mul(_MathBinaryOp):
|
|||
"""
|
||||
Multiplies two tensors element-wise.
|
||||
|
||||
Inputs of `x` and `y` comply with the implicit type conversion rules to make the data types consistent.
|
||||
The inputs must be two tensors or one tensor and one scalar.
|
||||
When the inputs are two tensors,
|
||||
dtypes of them cannot be bool at the same time, and the shapes of them could be broadcast.
|
||||
When the inputs are one tensor and one scalar,
|
||||
the scalar could only be a constant.
|
||||
|
||||
.. math::
|
||||
|
||||
out_{i} = x_{i} * y_{i}
|
||||
.. note::
|
||||
- Inputs of `x` and `y` comply with the
|
||||
`implicit type conversion rules <https://www.mindspore.cn/docs/note/en/master/operator_list_implicit.html>`_
|
||||
to make the data types consistent.
|
||||
- The inputs must be two tensors or one tensor and one scalar.
|
||||
- When the inputs are two tensors,
|
||||
dtypes of them cannot be bool at the same time, and the shapes of them can be broadcast.
|
||||
- When the inputs are one tensor and one scalar, the scalar could only be a constant.
|
||||
|
||||
Inputs:
|
||||
- **x** (Union[Tensor, Number, bool]) - The first input is a number or
|
||||
a bool or a tensor whose data type is number or bool.
|
||||
- **y** (Union[Tensor, Number, bool]) - The second input is a number or
|
||||
a bool when the first input is a tensor or a tensor whose data type is number or bool.
|
||||
- **x** (Union[Tensor, number.Number, bool]) - The first input is a number.Number or
|
||||
a bool or a tensor whose data type is
|
||||
`number <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_ or
|
||||
`bool_ <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_.
|
||||
- **y** (Union[Tensor, number.Number, bool]) - The second input, when the first input is a Tensor,
|
||||
the second input should be a number.Number or bool value, or a Tensor whose data type is number or bool_.
|
||||
When the first input is Scalar, the second input must be a Tensor whose data type is number or bool_.
|
||||
|
||||
Outputs:
|
||||
Tensor, the shape is the same as the one after broadcasting,
|
||||
and the data type is the one with higher precision or higher digits among the two inputs.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` and `y` is not one of the following: Tensor, Number, bool.
|
||||
TypeError: If `x` and `y` is not one of the following: Tensor, number.Number, bool.
|
||||
ValueError: If `x` and `y` are not the same shape.
|
||||
|
||||
Supported Platforms:
|
||||
|
@ -2145,31 +2161,37 @@ class Reciprocal(PrimitiveWithInfer):
|
|||
|
||||
class Pow(Primitive):
|
||||
"""
|
||||
Computes a tensor to the power of the second input.
|
||||
|
||||
Inputs of `x` and `y` comply with the implicit type conversion rules to make the data types consistent.
|
||||
The inputs must be two tensors or one tensor and one scalar.
|
||||
When the inputs are two tensors,
|
||||
dtypes of them cannot be bool at the same time, and the shapes of them could be broadcast.
|
||||
When the inputs are one tensor and one scalar,
|
||||
the scalar could only be a constant.
|
||||
Calculates the `y` power of each element in `x`.
|
||||
|
||||
.. math::
|
||||
|
||||
out_{i} = x_{i} ^{ y_{i}}
|
||||
|
||||
.. note::
|
||||
- Inputs of `x` and `y` comply with the
|
||||
`implicit type conversion rules <https://www.mindspore.cn/docs/note/en/master/operator_list_implicit.html>`_
|
||||
to make the data types consistent.
|
||||
- The inputs must be two tensors or one tensor and one scalar.
|
||||
- When the inputs are two tensors,
|
||||
dtypes of them cannot be bool at the same time, and the shapes of them can be broadcast.
|
||||
- When the inputs are one tensor and one scalar, the scalar could only be a constant.
|
||||
|
||||
Inputs:
|
||||
- **x** (Union[Tensor, Number, bool]) - The first input is a number or
|
||||
a bool or a tensor whose data type is number or bool.
|
||||
- **y** (Union[Tensor, Number, bool]) - The second input is a number or
|
||||
a bool when the first input is a tensor or a tensor whose data type is number or bool.
|
||||
- **x** (Union[Tensor, number.Number, bool]) - The first input is a number.Number or
|
||||
a bool or a tensor whose data type is
|
||||
`number <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_ or
|
||||
`bool_ <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_.
|
||||
- **y** (Union[Tensor, number.Number, bool]) - The second input, when the first input is a Tensor,
|
||||
the second input should be a number.Number or bool value, or a Tensor whose data type is number or bool_.
|
||||
When the first input is Scalar, the second input must be a Tensor whose data type is number or bool_.
|
||||
|
||||
Outputs:
|
||||
Tensor, the shape is the same as the one after broadcasting,
|
||||
and the data type is the one with higher precision or higher digits among the two inputs.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` and `y` is not one of the following: Tensor, Number, bool.
|
||||
TypeError: If `x` and `y` is not one of the following: Tensor, number.Number or bool.
|
||||
ValueError: If `x` and `y` are not the same shape.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
@ -2357,13 +2379,15 @@ class Log(PrimitiveWithInfer):
|
|||
y_i = log_e(x_i)
|
||||
|
||||
.. warning::
|
||||
If the input value of operator Log is within the range (0, 0.01] or [0.95, 1.05], the output accuracy
|
||||
is subject to change.
|
||||
If the input value of operator Log is within the range (0, 0.01] or [0.95, 1.05], the output accuracy may
|
||||
be affacted.
|
||||
|
||||
Inputs:
|
||||
- **x** (Tensor) - The input tensor. The data type must be float16, float32 or float64. The value must be
|
||||
greater than 0. :math:`(N,*)` where :math:`*` means, any number of additional dimensions, its rank should
|
||||
be less than 8.
|
||||
- **x** (Tensor) - Input Tensor of any dimension. The value must be greater than 0.
|
||||
|
||||
.. note::
|
||||
The dimension of the input Tensor on Ascend should be less than or equal to 8, and the dimension of the
|
||||
input Tensor on the CPU should be less than 8.
|
||||
|
||||
Outputs:
|
||||
Tensor, has the same shape and dtype as the `x`.
|
||||
|
@ -2449,8 +2473,8 @@ class Erf(Primitive):
|
|||
erf(x)=\frac{2} {\sqrt{\pi}} \int\limits_0^{x} e^{-t^{2}} dt
|
||||
|
||||
Inputs:
|
||||
- **x** (Tensor) - The input tensor. The data type must be float16 or float32.
|
||||
:math:`(N,*)` where :math:`*` means, any number of additional dimensions, its rank should be less than 8.
|
||||
- **x** (Tensor) - Input Tensor of Gaussian error function. Its dimension must be less than 8 and
|
||||
data type must be float16 or float32.
|
||||
|
||||
Outputs:
|
||||
Tensor, has the same shape and dtype as the `x`.
|
||||
|
@ -2672,32 +2696,35 @@ class Div(_MathBinaryOp):
|
|||
r"""
|
||||
Computes the quotient of dividing the first input tensor by the second input tensor element-wise.
|
||||
|
||||
Inputs of `x` and `y` comply with the implicit type conversion rules to make the data types consistent.
|
||||
The inputs must be two tensors or one tensor and one scalar.
|
||||
When the inputs are two tensors,
|
||||
dtypes of them cannot be bool at the same time, and the shapes of them could be broadcast.
|
||||
When the inputs are one tensor and one scalar,
|
||||
the scalar could only be a constant.
|
||||
|
||||
.. math::
|
||||
|
||||
out_{i} = \frac{x_i}{y_i}
|
||||
|
||||
.. note::
|
||||
- Inputs of `x` and `y` comply with the
|
||||
`implicit type conversion rules <https://www.mindspore.cn/docs/note/en/master/operator_list_implicit.html>`_
|
||||
to make the data types consistent.
|
||||
- The inputs must be two tensors or one tensor and one scalar.
|
||||
- When the inputs are two tensors,
|
||||
dtypes of them cannot be bool at the same time, and the shapes of them can be broadcast.
|
||||
- When the inputs are one tensor and one scalar, the scalar could only be a constant.
|
||||
|
||||
Inputs:
|
||||
- **x** (Union[Tensor, number.Number, bool]) - The first input is a number.Number or
|
||||
a bool or a tensor whose data type is
|
||||
`number <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_ or
|
||||
`bool_ <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_.
|
||||
- **y** (Union[Tensor, number.Number, bool]) - The second input is a number.Number or
|
||||
a bool when the first input is a tensor or a tensor whose data type is number or bool\_.
|
||||
When the first input is Scalar, the second input must be a Tensor whose data type is number or bool\_.
|
||||
- **y** (Union[Tensor, number.Number, bool]) - The second input, when the first input is a Tensor,
|
||||
the second input should be a number.Number or bool value, or a Tensor whose data type is number or bool_.
|
||||
When the first input is Scalar, the second input must be a Tensor whose data type is number or bool_.
|
||||
|
||||
Outputs:
|
||||
Tensor, the shape is the same as the one after broadcasting,
|
||||
Tensor, the shape is the same as the one of the input `x` , `y` after broadcasting,
|
||||
and the data type is the one with higher precision or higher digits among the two inputs.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` and `y` is not a number.Number or a bool or a Tensor.
|
||||
TypeError: If neither `x` nor `y` is a Tensor.
|
||||
TypeError: If data types of `x` and `y` are both Tensor with bool_.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
@ -2711,8 +2738,8 @@ class Div(_MathBinaryOp):
|
|||
>>> print(output)
|
||||
[-1.3333334 2.5 2. ]
|
||||
>>> # case 2 : different data type and shape of the two inputs
|
||||
>>> x = Tensor(np.array([-4.0, 5.0, 6.0]), mindspore.int32)
|
||||
>>> y = Tensor(2, mindspore.float32)
|
||||
>>> x = Tensor(np.array([-4.0, 5.0, 6.0]), mindspore.float32)
|
||||
>>> y = Tensor(2, mindspore.int32)
|
||||
>>> output = div(x, y)
|
||||
>>> print(output)
|
||||
[-2. 2.5 3.]
|
||||
|
@ -3837,13 +3864,6 @@ class LessEqual(_LogicBinaryOp):
|
|||
r"""
|
||||
Computes the boolean value of :math:`x <= y` element-wise.
|
||||
|
||||
Inputs of `x` and `y` comply with the implicit type conversion rules to make the data types consistent.
|
||||
The inputs must be two tensors or one tensor and one scalar.
|
||||
When the inputs are two tensors,
|
||||
dtypes of them cannot be both bool , and the shapes of them could be broadcast.
|
||||
When the inputs are one tensor and one scalar,
|
||||
the scalar could only be a constant.
|
||||
|
||||
.. math::
|
||||
|
||||
out_{i} =\begin{cases}
|
||||
|
@ -3851,14 +3871,26 @@ class LessEqual(_LogicBinaryOp):
|
|||
& \text{False, if } x_{i}>y_{i}
|
||||
\end{cases}
|
||||
|
||||
.. note::
|
||||
- Inputs of `x` and `y` comply with the
|
||||
`implicit type conversion rules <https://www.mindspore.cn/docs/note/en/master/operator_list_implicit.html>`_
|
||||
to make the data types consistent.
|
||||
- The inputs must be two tensors or one tensor and one scalar.
|
||||
- When the inputs are two tensors,
|
||||
dtypes of them cannot be both bool , and the shapes of them can be broadcast.
|
||||
- When the inputs are one tensor and one scalar, the scalar could only be a constant.
|
||||
|
||||
Inputs:
|
||||
- **x** (Union[Tensor, Number, bool]) - The first input is a number or
|
||||
a bool or a tensor whose data type is number or bool.
|
||||
- **y** (Union[Tensor, Number, bool]) - The second input is a number or
|
||||
a bool when the first input is a tensor or a tensor whose data type is number or bool.
|
||||
- **x** (Union[Tensor, number.Number, bool]) - The first input is a number.Number or
|
||||
a bool or a tensor whose data type is
|
||||
`number <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_ or
|
||||
`bool_ <https://www.mindspore.cn/docs/api/en/master/api_python/mindspore.html#mindspore.dtype>`_.
|
||||
- **y** (Union[Tensor, number.Number, bool]) - The second input, when the first input is a Tensor,
|
||||
the second input should be a number.Number or bool value, or a Tensor whose data type is number or bool_.
|
||||
When the first input is Scalar, the second input must be a Tensor whose data type is number or bool_.
|
||||
|
||||
Outputs:
|
||||
Tensor, the shape is the same as the one after broadcasting,and the data type is bool.
|
||||
Tensor, the shape is the same as the one after broadcasting, and the data type is bool.
|
||||
|
||||
Raises:
|
||||
TypeError: If neither `x` nor `y` is a Tensor.
|
||||
|
@ -5204,15 +5236,20 @@ class Invert(Primitive):
|
|||
|
||||
class Eps(PrimitiveWithInfer):
|
||||
"""
|
||||
Creates a tensor filled with minimum value in `x` dtype.
|
||||
Create a Tensor with the same data type and shape as input, and the element value is the minimum value that the
|
||||
corresponding data type can be expressed.
|
||||
|
||||
Inputs:
|
||||
- **x** (Tensor) - Input tensor. The data type must be float16, float32 or float64.
|
||||
:math:`(N,*)` where :math:`*` means, any number of additional dimensions.
|
||||
- **x** (Tensor) - Tensor of any dimension used to obtain the minimum value that its data type can be expressed.
|
||||
The data type must be float16, float32 or float64.
|
||||
|
||||
Outputs:
|
||||
Tensor, has the same type and shape as `x`, but filled with `x` dtype minimum val.
|
||||
|
||||
Raises:
|
||||
TypeError: If `x` is not a Tensor.
|
||||
TypeError: If data type of `x` is neither float16 nor float32.
|
||||
|
||||
Supported Platforms:
|
||||
``Ascend`` ``GPU`` ``CPU``
|
||||
|
||||
|
|
|
@ -565,7 +565,7 @@ class Mish(PrimitiveWithInfer):
|
|||
|
||||
class SeLU(Primitive):
|
||||
r"""
|
||||
Computes SeLU (scaled exponential Linear Unit) of input tensors element-wise.
|
||||
Activation function SeLU (Scaled exponential Linear Unit).
|
||||
|
||||
The activation function is defined as:
|
||||
|
||||
|
@ -583,8 +583,7 @@ class SeLU(Primitive):
|
|||
See more details in `Self-Normalizing Neural Networks <https://arxiv.org/abs/1706.02515>`_.
|
||||
|
||||
Inputs:
|
||||
- **input_x** (Tensor) - Tensor of shape :math:`(N, *)`, where :math:`*` means, any number of
|
||||
additional dimensions, with float16 or float32 data type.
|
||||
- **input_x** (Tensor) - Tensor of any dimension, the data type is float16 or float32.
|
||||
|
||||
Outputs:
|
||||
Tensor, with the same type and shape as the `input_x`.
|
||||
|
@ -666,16 +665,12 @@ class ReLUV2(Primitive):
|
|||
|
||||
\text{ReLU}(x) = (x)^+ = \max(0, x)
|
||||
|
||||
Note:
|
||||
The difference from `ReLu` is that the operator will output one more Mask,
|
||||
and the kernel of the operator is different from `ReLu`.
|
||||
|
||||
Inputs:
|
||||
- **input_x** (Tensor) - The input tensor must be a 4-D tensor.
|
||||
|
||||
Outputs:
|
||||
- **output** (Tensor) - Has the same type and shape as the `input_x`.
|
||||
- **mask** (Tensor) - A tensor whose data type must be uint8.
|
||||
- **mask** (Tensor) - A tensor, but it is meaningless.
|
||||
|
||||
Raises:
|
||||
TypeError: If `input_x` is not a Tensor.
|
||||
|
@ -687,17 +682,12 @@ class ReLUV2(Primitive):
|
|||
Examples:
|
||||
>>> input_x = Tensor(np.array([[[[1, -2], [-3, 4]], [[-5, 6], [7, -8]]]]), mindspore.float32)
|
||||
>>> relu_v2 = ops.ReLUV2()
|
||||
>>> output, mask= relu_v2(input_x)
|
||||
>>> output, _= relu_v2(input_x)
|
||||
>>> print(output)
|
||||
[[[[1. 0.]
|
||||
[0. 4.]]
|
||||
[[0. 6.]
|
||||
[7. 0.]]]]
|
||||
>>> print(mask)
|
||||
[[[[[1 0]
|
||||
[2 0]]
|
||||
[[2 0]
|
||||
[1 0]]]]]
|
||||
"""
|
||||
|
||||
@prim_attr_register
|
||||
|
@ -824,8 +814,7 @@ class Sigmoid(Primitive):
|
|||
where :math:`x_i` is an element of the input Tensor.
|
||||
|
||||
Inputs:
|
||||
- **input_x** (Tensor) - Tensor of shape :math:`(N, *)`, where :math:`*` means, any number of
|
||||
additional dimensions, with float16 or float32 data type.
|
||||
- **input_x** (Tensor) - Tensor of any dimension, the data type is float16 or float32.
|
||||
|
||||
Outputs:
|
||||
Tensor, with the same type and shape as the input_x.
|
||||
|
@ -2641,18 +2630,18 @@ class SoftMarginLoss(Primitive):
|
|||
|
||||
class L2Loss(Primitive):
|
||||
r"""
|
||||
Calculates half of the L2 norm of a tensor without sqrt.
|
||||
Calculates the L2 norm, but do not square the result.
|
||||
|
||||
Set `input_x` as x and output as loss.
|
||||
Set input as x and output as loss.
|
||||
|
||||
.. math::
|
||||
loss = \frac{\sum x ^ 2}{2}
|
||||
|
||||
Inputs:
|
||||
- **input_x** (Tensor) - A input Tensor. Data type must be float16 or float32.
|
||||
- **input_x** (Tensor) - Tensor for computing the L2 norm. Data type must be float16 or float32.
|
||||
|
||||
Outputs:
|
||||
Tensor, has the same dtype as `input_x`. The output tensor is the value of loss which is a scalar tensor.
|
||||
Tensor, has a Scalar Tensor with the same data type as `input_x`.
|
||||
|
||||
Raises:
|
||||
TypeError: If `input_x` is not a Tensor.
|
||||
|
@ -3392,12 +3381,13 @@ class GeLU(Primitive):
|
|||
GeLU is defined as follows:
|
||||
|
||||
.. math::
|
||||
\text{output} = 0.5 * x * (1 + tanh(x / \sqrt{2})),
|
||||
GELU(x_i) = x_i*P(X < x_i)
|
||||
|
||||
where :math:`tanh` is the hyperbolic tangent.
|
||||
where :math:`P` is the cumulative distribution function of the standard Gaussian distribution,
|
||||
:math:`x_i` is the input element.
|
||||
|
||||
Inputs:
|
||||
- **x** (Tensor) - Input to compute the GeLU with data type of float16 or float32.
|
||||
- **x** (Tensor) - The input of the activation function GeLU, the data type is float16 or float32.
|
||||
|
||||
Outputs:
|
||||
Tensor, with the same type and shape as `x`.
|
||||
|
@ -3544,11 +3534,10 @@ class PReLU(PrimitiveWithInfer):
|
|||
where :math:`x_i` is an element of a channel of the input, `w` is the weight of the channel.
|
||||
|
||||
Note:
|
||||
0-D or 1-D input_x is not supported on Ascend.
|
||||
Scalar or 1-D input x is not supported on Ascend.
|
||||
|
||||
Inputs:
|
||||
- **x** (Tensor) - The first input tensor, representing the output of the preview layer.
|
||||
With data type of float16 or float32.
|
||||
- **x** (Tensor) - The input Tensor of the activation function. The data type is float16 or float32.
|
||||
The shape is :math:`(N, C, *)` where :math:`*` means, any number of additional dimensions.
|
||||
- **weight** (Tensor) - Weight Tensor. The data type is float16 or float32.
|
||||
The weight can only be a vector, and the length is the same as the number of channels C of the `input_x`.
|
||||
|
|
|
@ -144,24 +144,38 @@ class Gamma(PrimitiveWithInfer):
|
|||
.. math::
|
||||
\text{P}(x|α,β) = \frac{\exp(-x/β)}{{β^α}\cdot{\Gamma(α)}}\cdot{x^{α-1}}
|
||||
|
||||
.. note::
|
||||
- Random seed: A set of regular random numbers can be obtained through some complex mathematical algorithms,
|
||||
and the random seed is the initial value of this random number. If the random seed is the same, the random
|
||||
number obtained will not change.
|
||||
- Global random seed and operator-level random seed are not set: Use the default value as the random seed.
|
||||
- Global random seed is set, but operator-level random seed is not set: A global random seed will splice
|
||||
with a randomly generated seed.
|
||||
- Global random seed is not set, operator-level random seed is set: The default global random seed is used,
|
||||
and splices with the operator-level random seed.
|
||||
- Both Global random and operator-level random seed are set: The global random seed will splice with the
|
||||
operator-level random seed.
|
||||
|
||||
Args:
|
||||
seed (int): Random seed, must be non-negative. Default: 0.
|
||||
seed2 (int): Random seed2, must be non-negative. Default: 0.
|
||||
seed (int): The operator-level random seed, used to generate random numbers, must be non-negative. Default: 0.
|
||||
seed2 (int): The global random seed and it will combile with the operator-level random seed to determine the
|
||||
final generated random number, must be non-negative. Default: 0.
|
||||
|
||||
Inputs:
|
||||
- **shape** (tuple) - The shape of random tensor to be generated. Only constant value is allowed.
|
||||
- **alpha** (Tensor) - The α distribution parameter. It must be greater than 0.
|
||||
It is also known as the shape parameter with float32 data type.
|
||||
- **beta** (Tensor) - The β distribution parameter. It must be greater than 0.
|
||||
It is also known as the inverse scale parameter with float32 data type.
|
||||
- **alpha** (Tensor) - α is the shape parameter of Gamma distribution, which mainly determines the shape of
|
||||
the curve. It must be greater than 0. The data type is float32.
|
||||
- **beta** (Tensor) - β is the inverse scale parameter of the Gamma distribution, which mainly determines how
|
||||
steep the curve is. It must be greater than 0. The data type is float32.
|
||||
|
||||
Outputs:
|
||||
Tensor. The shape must be the broadcasted shape of Input "shape" and shapes of alpha and beta.
|
||||
Tensor. The shape must be the broadcasted shape of Input "shape" and shapes of `alpha` and `beta`.
|
||||
The dtype is float32.
|
||||
|
||||
Raises:
|
||||
TypeError: If neither `seed` nor `seed2` is an int.
|
||||
TypeError: If neither `alpha` nor `beta` is a Tensor.
|
||||
TypeError: If data type of `seed` or `seed2` is not int.
|
||||
TypeError: If `alpha` or `beta` is not a Tensor.
|
||||
TypeError: If data type of `alpha` or `beta` is not float32.
|
||||
ValueError: If `shape` is not a constant value.
|
||||
|
||||
Supported Platforms:
|
||||
|
@ -346,20 +360,30 @@ class UniformInt(PrimitiveWithInfer):
|
|||
|
||||
class UniformReal(StandardNormal):
|
||||
r"""
|
||||
Produces random floating-point values i, uniformly distributed to the interval [0, 1).
|
||||
Produces random floating-point values, uniformly distributed to the interval [0, 1).
|
||||
|
||||
Args:
|
||||
seed (int): Random seed, must be non-negative. Default: 0.
|
||||
seed2 (int): Random seed2, must be non-negative. Default: 0.
|
||||
seed (int): The operator-level random seed, used to generate random numbers, must be non-negative. Default: 0.
|
||||
seed2 (int): The global random seed and it will combile with the operator-level random seed to determine the
|
||||
final generated random number, must be non-negative. Default: 0.
|
||||
|
||||
.. note::
|
||||
- Global random seed and operator-level random seed are not set: Use the default value as the random seed.
|
||||
- Global random seed is set, but operator-level random seed is not set: A global random seed will splice
|
||||
with a randomly generated seed.
|
||||
- Global random seed is not set, operator-level random seed is set: The default global random seed is used,
|
||||
and splices with the operator-level random seed.
|
||||
- Both Global random and operator-level random seed are set: The global random seed will splice with the
|
||||
operator-level random seed.
|
||||
|
||||
Inputs:
|
||||
- **shape** (tuple) - The shape of random tensor to be generated. Only constant value is allowed.
|
||||
- **shape** (tuple) - The shape of tensor to be generated. Only constant value is allowed.
|
||||
|
||||
Outputs:
|
||||
Tensor. The shape that the input 'shape' denotes. The dtype is float32.
|
||||
|
||||
Raises:
|
||||
TypeError: If neither `seed` nor `seed2` is an int.
|
||||
TypeError: If `seed` or `seed2` is not an int.
|
||||
TypeError: If `shape` is not a tuple.
|
||||
ValueError: If `shape` is not a constant value.
|
||||
|
||||
|
|
Loading…
Reference in New Issue