diff --git a/docs/api/api_python/ops/mindspore.ops.func_arange.rst b/docs/api/api_python/ops/mindspore.ops.func_arange.rst index 0fe2189040c..1d8f6c0c1ca 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_arange.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_arange.rst @@ -11,7 +11,7 @@ mindspore.ops.arange - **step** (Union[float, int, Tensor], 可选) - 表述序列中数值的步长。如果为Tensor,则shape必须为()。默认值:1。 关键字参数: - - **dtype** (mindspore.dtype, 可选) - 返回序列的数据类型。默认值:None。如果未指定或者为None,将会被推断为 `start` 、 `end` 和 `step` 参数中精度最高的类型。 + - **dtype** (mindspore.dtype, 可选) - 返回Tensor的所需数据类型。默认值:None。如果未指定或者为None,将会被推断为 `start` 、 `end` 和 `step` 参数中精度最高的类型。 返回: 一维Tensor,数据类型与输入数据类型一致。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_cov.rst b/docs/api/api_python/ops/mindspore.ops.func_cov.rst index 58798de1336..6f3c8b94d1f 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_cov.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_cov.rst @@ -3,9 +3,9 @@ mindspore.ops.cov .. py:function:: mindspore.ops.cov(x, *, correction=1, fweights=None, aweights=None) - 给定输入 `x` 和权重,估计输入 `x` 的协方差矩阵,其中输入的行是变量,列是观察值。 + 给定输入 `x` 和权重,返回输入 `x` 的协方差矩阵(每对变量的协方差的方阵),其中输入行是变量,列是观察值。 - 协方差矩阵是每对变量的协方差的方阵。对角线包含每个变量与其自身的协方差。若 `x` 表示单个变量(标量或一维),则返回其方差。 + 对角线包含每个变量及其自身的协方差。如果 `x` 是单个变量的标量或一维向量,则将返回其方差。 变量 :math:`a` 和 :math:`b` 的无偏样本协方差由下式给出: diff --git a/docs/api/api_python/ops/mindspore.ops.func_nan_to_num.rst b/docs/api/api_python/ops/mindspore.ops.func_nan_to_num.rst index 3e2ccdc07e5..ccad2eccecf 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_nan_to_num.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_nan_to_num.rst @@ -3,7 +3,7 @@ mindspore.ops.nan_to_num .. py:function:: mindspore.ops.nan_to_num(x, nan=0.0, posinf=None, neginf=None) - 将 `x` 中的 `NaN` 、正无穷大和负无穷大值分别替换为 `nan`, `posinf`, 和 `neginf` 指定的值。默认情况下,NaN替换为0,正无穷替换为 `x` 类型支持的上限,负无穷替换为由 `x` 类型支持的下限。 + 将 `x` 中的 `NaN` 、正无穷大和负无穷大值分别替换为 `nan`, `posinf`, 和 `neginf` 指定的值。 参数: - **x** (Tensor) - shape为 :math:`(x_1, x_2, ..., x_R)` 的tensor。类型必须为float32或float16。 diff --git a/docs/api/api_python/ops/mindspore.ops.func_sgn.rst b/docs/api/api_python/ops/mindspore.ops.func_sgn.rst index f7b421ba674..58f4d43869e 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_sgn.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_sgn.rst @@ -3,7 +3,9 @@ mindspore.ops.sgn .. py:function:: mindspore.ops.sgn(x) - 此方法为 :func:`mindspore.ops.sign` 在复数Tensor上的扩展。 + :func:`mindspore.ops.sign` 在复数上的扩展。 + 对于实数输入,此方法与 :func:`mindspore.ops.sign` 一致。 + 对于复数输入,此方法按照如下公式计算。 .. math:: \text{out}_{i} = \begin{cases} diff --git a/docs/api/api_python/ops/mindspore.ops.func_tanhshrink.rst b/docs/api/api_python/ops/mindspore.ops.func_tanhshrink.rst index 48321b8392a..789663e71c5 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_tanhshrink.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_tanhshrink.rst @@ -3,6 +3,6 @@ mindspore.ops.tanhshrink .. py:function:: mindspore.ops.tanhshrink(x) - 按元素计算 :math:`Tanhshrink(x)=x-Tanh(x)` 。 + Tanhshrink激活函数, :math:`Tanhshrink(x)=x-Tanh(x)` 。 详情请查看 :class:`mindspore.nn.Tanhshrink` 。 \ No newline at end of file diff --git a/mindspore/python/mindspore/common/tensor.py b/mindspore/python/mindspore/common/tensor.py index 38bc927d83b..63086563d78 100644 --- a/mindspore/python/mindspore/common/tensor.py +++ b/mindspore/python/mindspore/common/tensor.py @@ -3873,8 +3873,8 @@ class Tensor(Tensor_): @property def mT(self): r""" - Returns a view of this tensor with the last two dimensions transposed. - x.mT is equivalent to x.swapaxes(-2, -1). + Returns the Tensor that exchanges the last two dimensions. + Accessing the attribute, x.mT, is equal to calling the method, x.swapaxes(-2, -1). For details, please refer to :func:`mindspore.Tensor.swapaxes`. """ return self.swapaxes(-2, -1) diff --git a/mindspore/python/mindspore/ops/composite/math_ops.py b/mindspore/python/mindspore/ops/composite/math_ops.py index 451709e6cee..7171d45d178 100644 --- a/mindspore/python/mindspore/ops/composite/math_ops.py +++ b/mindspore/python/mindspore/ops/composite/math_ops.py @@ -659,12 +659,13 @@ def mm(mat1, mat2): :math:`(m \times p)` Tensor, `out` will be a :math:`(n \times p)` Tensor. Note: - This function does not broadcast. For broadcasting matrix products, see :func:`mindspore.ops.matmul`. + This function cannot support broadcasting. + Refer to :func:`mindspore.ops.matmul` instead if you need a broadcastable function. Args: - mat1 (Tensor): The first matrix to be matrix multiplied. + mat1 (Tensor): The first matrix of matrix multiplication. The last dimension of `mat1` must be the same size as the first dimension of `mat2`. - mat2 (Tensor): The second matrix to be matrix multiplied. + mat2 (Tensor): The second matrix of matrix multiplication. The last dimension of `mat1` must be the same size as the first dimension of `mat2`. Returns: diff --git a/mindspore/python/mindspore/ops/function/array_func.py b/mindspore/python/mindspore/ops/function/array_func.py index b0b75adec9e..63e9f16882d 100644 --- a/mindspore/python/mindspore/ops/function/array_func.py +++ b/mindspore/python/mindspore/ops/function/array_func.py @@ -175,9 +175,9 @@ def arange(start=0, end=None, step=1, *, dtype=None): If Tensor, the shape must be (). Default: 1. Keyword Args: - dtype (mindspore.dtype, optional): The desired data type of returned tensor. Default: None. - If dtype is not given or None, the dtype is inferred to be the type with the highest precision among - the `start`, `end` and `step` parameters. + dtype (mindspore.dtype, optional): The required data type of returned Tensor. Default: None. + If the value is not specified or is None, the type with the highest precision in the + `start`, `end`, and `step` parameters is inferred. Returns: A 1-D Tensor, with the same type as the inputs. diff --git a/mindspore/python/mindspore/ops/function/math_func.py b/mindspore/python/mindspore/ops/function/math_func.py index 2cdd9a84092..01e02310b6e 100644 --- a/mindspore/python/mindspore/ops/function/math_func.py +++ b/mindspore/python/mindspore/ops/function/math_func.py @@ -1716,10 +1716,10 @@ def signbit(x): Examples: >>> import mindspore as ms >>> import mindspore.ops as ops - >>> x = ms.Tensor([0.7, -1.2, 0., 2.3]) + >>> x = ms.Tensor([0.3, 1.2, 0., -2.5]) >>> output = ops.signbit(x) >>> print(output) - [False True False False] + [False False False True] """ if not isinstance(x, Tensor): raise TypeError(f"For signbit, the input must be a Tensor, but got {type(x)}") @@ -1729,7 +1729,9 @@ def signbit(x): def sgn(x): r""" - This function is an extension of :func:`mindspore.ops.sign` to complex tensors. + Extension of :func:`mindspore.ops.sign` in the plural. + For real number input, this function is the same as :func:`mindspore.ops.sign`. + For complex input, this function is calculated according to the following formula. .. math:: \text{out}_{i} = \begin{cases} @@ -1869,7 +1871,7 @@ def cos(x): def cosine_similarity(x1, x2, dim=1, eps=1e-08): r""" - Returns cosine similarity between x1 and x2, computed along dim. x1 and x2 must be broadcastable to a common shape. + Calculate cosine similarity between `x1` and `x2` along the axis, `dim`. `x1` and `x2` must be broadcastable. .. math:: \text{similarity} = \dfrac{x_1 \cdot x_2}{\max(\Vert x_1 \Vert _2 \cdot \Vert x_2 \Vert _2, \epsilon)} @@ -1877,8 +1879,8 @@ def cosine_similarity(x1, x2, dim=1, eps=1e-08): Args: x1 (Tensor): The first input Tensor. x2 (Tensor): The second input Tensor. - dim (int, optional): Dimension along which cosine similarity is computed. Default: 1. - eps (float, optional): Small value to avoid division by zero. Default: 1e-8. + dim (int, optional): Axis for calculating cosine similarity. Default: 1. + eps (float, optional): Minimal value to avoid division by zero. Default: 1e-8. Returns: Tensor, cosine similarity between x1 and x2. @@ -1923,14 +1925,13 @@ def _check_cov_weights(weights, weights_name, num_observations, valid_type, vali def cov(x, *, correction=1, fweights=None, aweights=None): r""" - Given the input 'x' and weight, estimate the covariance matrix of the input 'x', where the input row is the variable - and the column is the observation value. + Given the input `x` and weights, returns the covariance matrix (the square matrix of the covariance of each pair of + variables) of x, where the input row is the variable and the column is the observation value. - The covariance matrix is the square matrix of the covariance of each pair of variables. The diagonal contains the - covariance of each variable and its own. If 'x' represents a single variable (scalar or 1D), - its variance is returned. + The diagonal contains each variable and its own covariance. If x is a scalar or 1D vector of a single variable, + its variance will be returned. - The unbiased sample covariance of the variables :math:`a` and :math:`b` is given by: + The unbiased sample covariance of the variables :math:`a` and :math:`b` is given by the following formula: .. math:: \text{cov}_w(a,b) = \frac{\sum^{N}_{i = 1}(a_{i} - \bar{a})(b_{i} - \bar{b})}{N~-~1} @@ -1954,12 +1955,12 @@ def cov(x, *, correction=1, fweights=None, aweights=None): x (Tensor): A 2D matrix, or a scalar or 1D vector of a single variable Keyword Args: - correction (int, optional): difference between the sample size and sample degrees of freedom. + correction (int, optional): The difference between sample size and sample degrees of freedom. Defaults to Bessel's correction, `correction = 1` which returns the unbiased estimate, even if both `fweights` and `aweights` are specified. `correction = 0` will return the simple average. Default: 1. - fweights (Tensor, optional): A scalar or 1D Tensor containing integer frequency weights represents - the number of repeats of each observation vector. Its numel must equal the number of columns of `x`. + fweights (Tensor, optional): Scalar or one-dimensional Tensor containing integer frequency weight, indicating + the number of repetition of each observation vector. Its numel must equal the number of columns of `x`. Ignored if `None`. Default: None. aweights (Tensor, optional): A scalar or 1D Tensor containing float observation weights represents the importance of each observation vector. The higher the importance, the greater the corresponding value. @@ -4136,19 +4137,17 @@ def is_complex(x): def nan_to_num(x, nan=0.0, posinf=None, neginf=None): """ - Replaces `NaN`, positive infinity, and negative infinity values in the `x` with the values - specified by `nan`, `posinf`, and `neginf`, respectively. By default, NaN is replaced by 0, - positive infinity is replaced by the largest finite value representable by the x dtype, - and negative infinity is replaced by the smallest finite value representable by the x dtype. + Replace the `NaN`, positive infinity and negative infinity values in 'x' with the + specified values, `nan`, `posinf`, and `neginf` respectively. Args: x (Tensor): The shape of tensor is :math:`(x_1, x_2, ..., x_R)`. With float32 or float16 data type. - nan (float): The value to replace `NaN`. Default value is 0.0. - posinf (float): If a Number, the value to replace positive infinity values with. If None, positive - infinity values are replaced with the greatest finite value representable by `x`'s dtype. + nan (float): The replace value of 'NaN'. Default value is 0.0. + posinf (float): the value to replace positive infinity values with. Default: None, + replacing positive infinity with the maximum value supported by the data type of `x`. Default value is None. - neginf (float): if a Number, the value to replace negative infinity values with. If None, negative - infinity values are replaced with the lowest finite value representable by `x`'s dtype. + neginf (float): the value to replace negative infinity values with. Default: None, + replacing negative infinity with the minimum value supported by the data type of `x`. Default value is None. Returns: @@ -4162,10 +4161,10 @@ def nan_to_num(x, nan=0.0, posinf=None, neginf=None): ``CPU`` Examples: - >>> x = Tensor(np.array([float('nan'), float('inf'), -float('inf'), 3.14]), mindspore.float32) + >>> x = Tensor(np.array([float('nan'), float('inf'), -float('inf'), 5.0]), mindspore.float32) >>> output = ops.nan_to_num(x, 1.0, 2.0, 3.0) >>> print(output) - [1. 2. 3. 3.14] + [1. 2. 3. 5.0] """ if not isinstance(x, (Tensor, Tensor_)): raise TypeError("the input x must be Tensor!") @@ -8315,7 +8314,7 @@ def roll(x, shifts, dims=None): TypeError: If `dims` is not an int, a tuple or a list. Supported Platforms: - ``Ascend`` ``GPU`` + ``GPU`` Examples: >>> import numpy as np @@ -10014,7 +10013,7 @@ def sum(x, dim=None, keepdim=False, *, dtype=None): def tanhshrink(x): ''' - Applies element-wise, :math:`Tanhshrink(x)=x-Tanh(x)` . + Tanhshrink Activation, :math:`Tanhshrink(x)=x-Tanh(x)` . See :class:`mindspore.nn.Tanhshrink` for more details. Supported Platforms: diff --git a/mindspore/python/mindspore/ops/function/nn_func.py b/mindspore/python/mindspore/ops/function/nn_func.py index bc7b632fc79..68582c4d4bf 100644 --- a/mindspore/python/mindspore/ops/function/nn_func.py +++ b/mindspore/python/mindspore/ops/function/nn_func.py @@ -5708,7 +5708,7 @@ def mse_loss(input_x, target, reduction='mean'): def msort(x): r""" - Sorts the elements of the input tensor along its first dimension in ascending order by value. + Sorts the elements in Tensor in ascending order of value along its first dimension. ops.msort(t) is equivalent to ops.Sort(axis=0)(t)[0]. See also :class:`mindspore.ops.Sort()`.