diff --git a/mindspore/common/tensor.py b/mindspore/common/tensor.py index 5223ea619f8..41c3b9c49d6 100644 --- a/mindspore/common/tensor.py +++ b/mindspore/common/tensor.py @@ -44,7 +44,7 @@ class Tensor(Tensor_): output tensor will be the same as the `input_data`. Default: None. shape (Union[tuple, list, int]): A list of integers, a tuple of integers or an integer as the shape of output. If `input_data` is available, `shape` doesn't need to be set. Default: None. - init (Initializer): the information of init data. + init (Initializer): The information of init data. 'init' is used for delayed initialization in parallel mode. Usually, it is not recommended to use 'init' interface to initialize parameters in other conditions. If 'init' interface is used to initialize parameters, the `Tensor.init_data` API needs to be called to convert `Tensor` to the actual data. diff --git a/mindspore/explainer/explanation/_attribution/_perturbation/replacement.py b/mindspore/explainer/explanation/_attribution/_perturbation/replacement.py index 1b13c87ea1e..4ddf8e72fe8 100644 --- a/mindspore/explainer/explanation/_attribution/_perturbation/replacement.py +++ b/mindspore/explainer/explanation/_attribution/_perturbation/replacement.py @@ -38,7 +38,7 @@ class BaseReplacement: 'EMPTY' to mark the required args. Initializing an object will check the given kwargs w.r.t '_necessary_args'. - Raise: + Raises: ValueError: Raise when provided kwargs not contain necessary arg names with 'EMPTY' mark. """ _necessary_args = {} diff --git a/mindspore/explainer/explanation/_counterfactual/hierarchical_occlusion.py b/mindspore/explainer/explanation/_counterfactual/hierarchical_occlusion.py index cfae2e4cd08..f5e6ecb1721 100644 --- a/mindspore/explainer/explanation/_counterfactual/hierarchical_occlusion.py +++ b/mindspore/explainer/explanation/_counterfactual/hierarchical_occlusion.py @@ -501,7 +501,7 @@ class Searcher: tuple[EditStep, list[float]], the root edit step and network output of each layer after applied the layer steps. - Raise: + Raises: TypeError: Be raised for any argument or data type problem. ValueError: Be raised for any argument or data value problem. NoValidResultError: Be raised if no valid result was found. @@ -566,7 +566,7 @@ class Searcher: tuple[EditStep, list[float]], the root edit step and network output of each layer after applied the layer steps. - Raise: + Raises: NoValidResultError: Be raised if no valid result was found. """ # the leaf layer's network output may not meet the threshold, @@ -634,7 +634,7 @@ class Searcher: Returns: numpy.ndarray, the image tensor workpiece. - Raise: + Raises: OriginalOutputError: Be raised if network output of the original image is not strictly larger than the threshold. """ @@ -674,7 +674,7 @@ class Searcher: Returns: tuple[list[EditStep], _StopReason], result edit stop and the stop reason. - Raise: + Raises: OriginalOutputError: Be raised if network output of the original image is not strictly larger than the threshold. """ diff --git a/mindspore/nn/layer/basic.py b/mindspore/nn/layer/basic.py index f1de87f44a8..3b567e05934 100644 --- a/mindspore/nn/layer/basic.py +++ b/mindspore/nn/layer/basic.py @@ -475,7 +475,7 @@ class Norm(Cell): otherwise a Tensor with dimensions in 'axis' removed is returned. The data type is the same with `x` Raises: - TypeError: If `axis` is neither an int nor tuple. + TypeError: If `axis` is neither an int nor a tuple. TypeError: If `keep_dims` is not a bool. Supported Platforms: @@ -669,17 +669,18 @@ class Pad(Cell): paddings are int type. For `D` th dimension of the `x`, paddings[D, 0] indicates how many sizes to be extended ahead of the `D` th dimension of the input tensor, and paddings[D, 1] indicates how many sizes to be extended behind of the `D` th dimension of the input tensor. The padded size of each dimension D of the - output is: :math:`paddings[D, 0] + input\_x.dim\_size(D) + paddings[D, 1]` - eg: + output is: :math:`paddings[D, 0] + input\_x.dim\_size(D) + paddings[D, 1]`, + e.g.: - - mode = "CONSTANT". - - paddings = [[1,1], [2,2]]. - - x = [[1,2,3], [4,5,6], [7,8,9]]. - - The above can be seen: 1st dimension of `x` is 3, 2nd dimension of `x` is 3. - - Substitute into the formula to get: - - 1st dimension of output is paddings[0][0] + 3 + paddings[0][1] = 1 + 3 + 1 = 4. - - 2nd dimension of output is paddings[1][0] + 3 + paddings[1][1] = 2 + 3 + 2 = 7. - - so output.shape is (4, 7) + .. code-block:: + mode = "CONSTANT". + paddings = [[1,1], [2,2]]. + x = [[1,2,3], [4,5,6], [7,8,9]]. + # The above can be seen: 1st dimension of `x` is 3, 2nd dimension of `x` is 3. + # Substitute into the formula to get: + # 1st dimension of output is paddings[0][0] + 3 + paddings[0][1] = 1 + 3 + 1 = 4. + # 2nd dimension of output is paddings[1][0] + 3 + paddings[1][1] = 2 + 3 + 2 = 7. + # So the shape of output is (4, 7). mode (str): Specifies padding mode. The optional values are "CONSTANT", "REFLECT", "SYMMETRIC". Default: "CONSTANT". diff --git a/mindspore/nn/layer/math.py b/mindspore/nn/layer/math.py index 7a6901660af..03913193c4b 100644 --- a/mindspore/nn/layer/math.py +++ b/mindspore/nn/layer/math.py @@ -919,6 +919,9 @@ class Moments(Cell): """ Calculates the mean and variance of `x`. + The mean and variance are calculated by aggregating the contents of `input_x` across axes. + If `input_x` is 1-D and axes = [0] this is just the mean and variance of a vector. + Args: axis (Union[int, tuple(int)]): Calculates the mean and variance along the specified axis. Default: None. keep_dims (bool): If true, The dimension of mean and variance are identical with input's. diff --git a/mindspore/nn/optim/momentum.py b/mindspore/nn/optim/momentum.py index 39b40d4ac18..15888ef66be 100755 --- a/mindspore/nn/optim/momentum.py +++ b/mindspore/nn/optim/momentum.py @@ -112,7 +112,7 @@ class Momentum(Optimizer): - **gradients** (tuple[Tensor]) - The gradients of `params`, the shape is the same as `params`. Outputs: - tuple[bool], all elements are True. + tuple[bool]. All elements are True. Raises: TypeError: If `learning_rate` is not one of int, float, Tensor, Iterable, LearningRateSchedule. diff --git a/mindspore/ops/composite/random_ops.py b/mindspore/ops/composite/random_ops.py index 6389f21ac9d..d56353a0e6d 100644 --- a/mindspore/ops/composite/random_ops.py +++ b/mindspore/ops/composite/random_ops.py @@ -149,7 +149,7 @@ def uniform(shape, minval, maxval, seed=None, dtype=mstype.float32): If dtype is int32, only one number is allowed. seed (int): Seed is used as entropy source for the random number engines to generate pseudo-random numbers, must be non-negative. Default: None, which will be treated as 0. - dtype (mindspore.dtype): type of the Uniform distribution. If it is int32, it generates numbers from discrete + dtype (mindspore.dtype): Type of the Uniform distribution. If it is int32, it generates numbers from discrete uniform distribution; if it is float32, it generates numbers from continuous uniform distribution. It only supports these two data types. Default: mindspore.float32. @@ -161,7 +161,7 @@ def uniform(shape, minval, maxval, seed=None, dtype=mstype.float32): Raises: TypeError: If `shape` is not tuple. TypeError: If 'minval' or 'maxval' is neither int32 nor float32 - and dtype of 'minval' is not the same as 'maxval' + and dtype of 'minval' is not the same as 'maxval'. TypeError: If `seed` is not an int. TypeError: If 'dtype' is neither int32 nor float32. diff --git a/mindspore/ops/operations/array_ops.py b/mindspore/ops/operations/array_ops.py index d95fd4a6e67..c02bed41898 100755 --- a/mindspore/ops/operations/array_ops.py +++ b/mindspore/ops/operations/array_ops.py @@ -1178,7 +1178,7 @@ class Size(PrimitiveWithInfer): - **input_x** (Tensor) - The shape of tensor is :math:`(x_1, x_2, ..., x_R)`. The data type is Number. Outputs: - int, a scalar representing the elements size of `input_x`, tensor is the number of elements + int. A scalar representing the elements size of `input_x`, tensor is the number of elements in a tensor, :math:`size=x_1*x_2*...x_R`. The data type is an int. Raises: @@ -2665,14 +2665,14 @@ class Slice(PrimitiveWithInfer): """ Slices a tensor in the specified shape. - Slice the tensor 'input_x` in shape of `size` and starting at the location specified by `begin`, + Slice the tensor `input_x` in shape of `size` and starting at the location specified by `begin`, The slice `begin` represents the offset in each dimension of `input_x`, The slice `size` represents the size of the output tensor. Note that `begin` is zero-based and `size` is one-based. If `size[i]` is -1, all remaining elements in dimension i are included in the slice. - This is equivalent to setting :math:`size[i] = input_x.shape(i) - begin[i]` + This is equivalent to setting :math:`size[i] = input_x.shape(i) - begin[i]`. Inputs: - **input_x** (Tensor): The target tensor. diff --git a/mindspore/ops/operations/nn_ops.py b/mindspore/ops/operations/nn_ops.py index 945bc7ee03f..76041b6fd06 100755 --- a/mindspore/ops/operations/nn_ops.py +++ b/mindspore/ops/operations/nn_ops.py @@ -479,7 +479,7 @@ class Mish(PrimitiveWithInfer): Supported Platforms: ``Ascend`` - Raise: + Raises: TypeError: If dtype of `x` is neither float16 nor float32. Examples: @@ -533,7 +533,7 @@ class SeLU(PrimitiveWithInfer): Supported Platforms: ``Ascend`` - Raise: + Raises: TypeError: If dtype of `input_x` is neither float16 nor float32. Examples: @@ -948,7 +948,7 @@ class InstanceNorm(PrimitiveWithInfer): Supported Platforms: ``GPU`` - Raise: + Raises: TypeError: If `epsilon` or `momentum` is not a float. TypeError: If dtype of `input_x` is neither float16 nor float32. TypeError: If dtype of `gamma`, `beta` or `mean` is not float32. diff --git a/mindspore/ops/operations/random_ops.py b/mindspore/ops/operations/random_ops.py index 0995d8b5350..e8b0cc9eafd 100644 --- a/mindspore/ops/operations/random_ops.py +++ b/mindspore/ops/operations/random_ops.py @@ -143,7 +143,7 @@ class Gamma(PrimitiveWithInfer): Produces random positive floating-point values x, distributed according to probability density function: .. math:: - \text{P}(x|α,β) = \frac{\exp(-x/β)}{{β^α}\cdot{\Gamma(α)}}\cdot{x^{α-1}}, + \text{P}(x|α,β) = \frac{\exp(-x/β)}{{β^α}\cdot{\Gamma(α)}}\cdot{x^{α-1}} Args: seed (int): Random seed, must be non-negative. Default: 0.