diff --git a/mindspore/common/tensor.py b/mindspore/common/tensor.py index 1b9d62b185..69c1e98f60 100644 --- a/mindspore/common/tensor.py +++ b/mindspore/common/tensor.py @@ -293,11 +293,11 @@ class Tensor(Tensor_): def view(self, *shape): - """ + r""" Reshape the tensor according to the input shape. Args: - shape (Union(list(int), *int)): Dimension of the output tensor. + shape (Union(list[int], \*int)): Dimension of the output tensor. Returns: Tensor, has the same dimension as the input shape. diff --git a/mindspore/context.py b/mindspore/context.py index 8c7bdc5d17..f17b174174 100644 --- a/mindspore/context.py +++ b/mindspore/context.py @@ -539,11 +539,10 @@ def set_context(**kwargs): - training_trace: collect iterative trajectory data, that is, the training task and software information of the AI software stack, to achieve performance analysis of the training task, focusing on data enhancement, forward and backward calculation, gradient aggregation update and other related data. - - task_trace: collect task trajectory data, that is, the hardware information of the HWTS/AICore of the Ascend 910 processor, and analyze the information of beginning and ending of the task. - - op_trace: collect single operator performance data. + The profiling can choose the combination of `training_trace`, `task_trace`, `training_trace` and `task_trace` combination, and eparated by colons; a single operator can choose `op_trace`, `op_trace` cannot be combined with diff --git a/mindspore/dataset/engine/datasets.py b/mindspore/dataset/engine/datasets.py index ab8ea415b8..2dee4cb28b 100644 --- a/mindspore/dataset/engine/datasets.py +++ b/mindspore/dataset/engine/datasets.py @@ -151,8 +151,9 @@ class Dataset: def parse_tree(self): """ Internal method to parse the API tree into an IR tree. + Returns: - DatasetNode. The root of the IR tree. + DatasetNode, The root of the IR tree. """ if len(self.parent) > 1: raise ValueError("The data pipeline is not a tree (i.e., one node has 2 consumers)") @@ -823,7 +824,7 @@ class Dataset: ValueError: If sizes is list of float and not all floats are between 0 and 1, or if the floats don’t sum to 1. - Returns + Returns: tuple(Dataset), a tuple of datasets that have been split. Examples: @@ -1516,10 +1517,10 @@ class Dataset: """ Get the class index. - Return: + Returns: Dict, A str-to-int mapping from label name to index. Dict, A str-to-list mapping from label name to index for Coco ONLY. The second number - in the list is used to indicate the super category + in the list is used to indicate the super category """ if self.children: return self.children[0].get_class_indexing() @@ -1710,7 +1711,7 @@ class MappableDataset(SourceDataset): ValueError: If sizes is list of float and not all floats are between 0 and 1, or if the floats don’t sum to 1. - Returns + Returns: tuple(Dataset), a tuple of datasets that have been split. Examples: @@ -4064,7 +4065,7 @@ class ManifestDataset(MappableDataset): """ Get the class index. - Return: + Returns: Dict, A str-to-int mapping from label name to index. """ if self.class_indexing is None: @@ -4720,7 +4721,7 @@ class VOCDataset(MappableDataset): """ Get the class index. - Return: + Returns: Dict, A str-to-int mapping from label name to index. """ if self.task != "Detection": @@ -4911,7 +4912,7 @@ class CocoDataset(MappableDataset): """ Get the class index. - Return: + Returns: Dict, A str-to-list mapping from label name to index """ if self.task not in {"Detection", "Panoptic"}: diff --git a/mindspore/explainer/explanation/_attribution/_perturbation/occlusion.py b/mindspore/explainer/explanation/_attribution/_perturbation/occlusion.py index a90d5b06f5..59563dd688 100644 --- a/mindspore/explainer/explanation/_attribution/_perturbation/occlusion.py +++ b/mindspore/explainer/explanation/_attribution/_perturbation/occlusion.py @@ -61,7 +61,7 @@ class Occlusion(PerturbationAttribution): Inputs: - **inputs** (Tensor) - The input data to be explained, a 4D tensor of shape :math:`(N, C, H, W)`. - **targets** (Tensor, int) - The label of interest. It should be a 1D or 0D tensor, or an integer. - If it is a 1D tensor, its length should be the same as `inputs`. + If it is a 1D tensor, its length should be the same as `inputs`. Outputs: Tensor, a 4D tensor of shape :math:`(N, 1, H, W)`. diff --git a/mindspore/nn/layer/activation.py b/mindspore/nn/layer/activation.py index 3d9c4bcb24..60d80b0503 100644 --- a/mindspore/nn/layer/activation.py +++ b/mindspore/nn/layer/activation.py @@ -365,8 +365,12 @@ class FastGelu(Cell): Applies FastGelu function to each element of the input. The input is a Tensor with any valid shape. FastGelu is defined as: - :math:`FastGelu(x_i) = \frac {x_i} {1 + \exp(-1.702 * \left| x_i \right|)} * - \exp(0.851 * (x_i - \left| x_i \right|))`, where :math:`x_i` is the element of the input. + + .. math:: + FastGelu(x_i) = \frac {x_i} {1 + \exp(-1.702 * \left| x_i \right|)} * + \exp(0.851 * (x_i - \left| x_i \right|)) + + where :math:`x_i` is the element of the input. Inputs: - **input_data** (Tensor) - The input of FastGelu with data type of float16 or float32. diff --git a/mindspore/nn/loss/loss.py b/mindspore/nn/loss/loss.py index f90f407c1a..2ebe54d475 100644 --- a/mindspore/nn/loss/loss.py +++ b/mindspore/nn/loss/loss.py @@ -221,7 +221,8 @@ class SoftmaxCrossEntropyWithLogits(_Loss): .. math:: \ell(x_i, t_i) = - \log\left(\frac{\exp(x_{t_i})}{\sum_j \exp(x_j)}\right) - = -x_{t_i} + \log\left(\sum_j \exp(x_j)\right), + = -x_{t_i} + \log\left(\sum_j \exp(x_j)\right) + where :math:`x_i` is a 1D score Tensor, :math:`t_i` is a scalar. Note: diff --git a/mindspore/nn/metrics/error.py b/mindspore/nn/metrics/error.py index 8ed175bc27..4b517d9d82 100644 --- a/mindspore/nn/metrics/error.py +++ b/mindspore/nn/metrics/error.py @@ -91,7 +91,8 @@ class MSE(Metric): norm) between each element in the input: :math:`x` and the target: :math:`y`. .. math:: - \text{MSE}(x,\ y) = \frac{\sum_{i=1}^n(y_i - x_i)^2}{n}, + \text{MSE}(x,\ y) = \frac{\sum_{i=1}^n(y_i - x_i)^2}{n} + where :math:`n` is batch size. Examples: diff --git a/mindspore/nn/probability/bijector/power_transform.py b/mindspore/nn/probability/bijector/power_transform.py index 90b42392a6..b9c65fc48e 100644 --- a/mindspore/nn/probability/bijector/power_transform.py +++ b/mindspore/nn/probability/bijector/power_transform.py @@ -26,6 +26,7 @@ class PowerTransform(Bijector): .. math:: Y = g(X) = (1 + X * c)^{1 / c}, X >= -1 / c + where c >= 0 is the power. The power transform maps inputs from `[-1/c, inf]` to `[0, inf]`. diff --git a/mindspore/nn/probability/bijector/scalar_affine.py b/mindspore/nn/probability/bijector/scalar_affine.py index d8b99f050c..a54b3cd7bb 100644 --- a/mindspore/nn/probability/bijector/scalar_affine.py +++ b/mindspore/nn/probability/bijector/scalar_affine.py @@ -25,6 +25,7 @@ class ScalarAffine(Bijector): .. math:: Y = a * X + b + where a is the scale factor and b is the shift factor. Args: diff --git a/mindspore/ops/operations/array_ops.py b/mindspore/ops/operations/array_ops.py index 0bd85e3143..d47b1b3d56 100644 --- a/mindspore/ops/operations/array_ops.py +++ b/mindspore/ops/operations/array_ops.py @@ -2610,6 +2610,7 @@ class StridedSlice(PrimitiveWithInfer): Outputs: Tensor. The output is explained by following example. + - In the 0th dimension, begin is 1, end is 2, and strides is 1, because :math:`1+1=2\geq2`, the interval is :math:`[1,2)`. Thus, return the element with :math:`index = 1` in 0th dimension, i.e., [[3, 3, 3], [4, 4, 4]]. @@ -2624,7 +2625,7 @@ class StridedSlice(PrimitiveWithInfer): Supported Platforms: ``Ascend`` ``GPU`` ``CPU`` - Examples + Examples: >>> input_x = Tensor([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]], ... [[5, 5, 5], [6, 6, 6]]], mindspore.float32) >>> slice = ops.StridedSlice()