diff --git a/mindspore/common/tensor.py b/mindspore/common/tensor.py index 7e69d5d4ca..3efed7e329 100644 --- a/mindspore/common/tensor.py +++ b/mindspore/common/tensor.py @@ -293,7 +293,7 @@ class Tensor(Tensor_): @property def dtype(self): - """Returns the dtype of the tensor (:class:`mindspore.dtype`).""" + """Return the dtype of the tensor (:class:`mindspore.dtype`).""" return self._dtype @property @@ -303,7 +303,7 @@ class Tensor(Tensor_): @property def ndim(self): - """Returns the number of tensor dimensions.""" + """Return the number of tensor dimensions.""" return len(self._shape) @property @@ -313,22 +313,22 @@ class Tensor(Tensor_): @property def itemsize(self): - """Returns the length of one tensor element in bytes.""" + """Return the length of one tensor element in bytes.""" return self._itemsize @property def strides(self): - """Returns the tuple of bytes to step in each dimension when traversing a tensor.""" + """Return the tuple of bytes to step in each dimension when traversing a tensor.""" return self._strides @property def nbytes(self): - """Returns the total number of bytes taken by the tensor.""" + """Return the total number of bytes taken by the tensor.""" return self._nbytes @property def T(self): - """Returns the transposed tensor.""" + """Return the transposed tensor.""" return self.transpose() @property @@ -439,7 +439,7 @@ class Tensor(Tensor_): def mean(self, axis=(), keep_dims=False): """ - Reduces a dimension of a tensor by averaging all elements in the dimension. + Reduce a dimension of a tensor by averaging all elements in the dimension. Args: axis (Union[None, int, tuple(int), list(int)]): Dimensions of reduction, @@ -456,7 +456,7 @@ class Tensor(Tensor_): def transpose(self, *axes): r""" - Returns a view of the tensor with axes transposed. + Return a view of the tensor with axes transposed. For a 1-D tensor this has no effect, as a transposed vector is simply the same vector. For a 2-D tensor, this is a standard matrix transpose. For a @@ -480,7 +480,7 @@ class Tensor(Tensor_): def reshape(self, *shape): """ - Gives a new shape to a tensor without changing its data. + Give a new shape to a tensor without changing its data. Args: shape(Union[int, tuple(int), list(int)]): The new shape should be compatible @@ -497,7 +497,7 @@ class Tensor(Tensor_): def ravel(self): """ - Returns a contiguous flattened tensor. + Return a contiguous flattened tensor. Returns: Tensor, a 1-D tensor, containing the same elements of the input. @@ -508,7 +508,7 @@ class Tensor(Tensor_): def flatten(self, order='C'): r""" - Returns a copy of the tensor collapsed into one dimension. + Return a copy of the tensor collapsed into one dimension. Args: order (str, optional): Can choose between 'C' and 'F'. 'C' means to @@ -531,7 +531,7 @@ class Tensor(Tensor_): def swapaxes(self, axis1, axis2): """ - Interchanges two axes of a tensor. + Interchange two axes of a tensor. Args: axis1 (int): First axis. @@ -561,7 +561,7 @@ class Tensor(Tensor_): def squeeze(self, axis=None): """ - Removes single-dimensional entries from the shape of a tensor. + Remove single-dimensional entries from the shape of a tensor. Args: axis (Union[None, int, list(int), tuple(int)], optional): Default is None. @@ -577,7 +577,7 @@ class Tensor(Tensor_): def astype(self, dtype, copy=True): """ - Returns a copy of the tensor, casted to a specified type. + Return a copy of the tensor, casted to a specified type. Args: dtype (Union[:class:`mindspore.dtype`, str]): Designated tensor dtype, can be in format diff --git a/mindspore/communication/management.py b/mindspore/communication/management.py index 1a8ecd4636..122b4515af 100755 --- a/mindspore/communication/management.py +++ b/mindspore/communication/management.py @@ -175,7 +175,7 @@ def get_local_rank_size(group=GlobalComm.WORLD_COMM_GROUP): def get_world_rank_from_group_rank(group, group_rank_id): """ - Gets the rank ID in the world communication group corresponding to + Get the rank ID in the world communication group corresponding to the rank ID in the specified user communication group. Note: diff --git a/mindspore/compression/quant/qat.py b/mindspore/compression/quant/qat.py index 94108d4f14..10d9758341 100644 --- a/mindspore/compression/quant/qat.py +++ b/mindspore/compression/quant/qat.py @@ -43,7 +43,7 @@ def create_quant_config(quant_observer=(nn.FakeQuantWithMinMaxObserver, nn.FakeQ symmetric=(False, False), narrow_range=(False, False)): r""" - Configs the observer type of weights and data flow with quant params. + Config the observer type of weights and data flow with quant params. Args: quant_observer (Union[Observer, list, tuple]): The observer type to do quantization. The first element represent diff --git a/mindspore/context.py b/mindspore/context.py index 1a4f5d70a8..2c83ea54ff 100644 --- a/mindspore/context.py +++ b/mindspore/context.py @@ -86,12 +86,12 @@ class _ThreadLocalInfo(threading.local): @property def reserve_class_name_in_scope(self): - """Gets whether to save the network class name in the scope.""" + """Get whether to save the network class name in the scope.""" return self._reserve_class_name_in_scope @reserve_class_name_in_scope.setter def reserve_class_name_in_scope(self, reserve_class_name_in_scope): - """Sets whether to save the network class name in the scope.""" + """Set whether to save the network class name in the scope.""" if not isinstance(reserve_class_name_in_scope, bool): raise ValueError( "Set reserve_class_name_in_scope value must be bool!") @@ -295,12 +295,12 @@ class _Context: @property def reserve_class_name_in_scope(self): - """Gets whether to save the network class name in the scope.""" + """Get whether to save the network class name in the scope.""" return self._thread_local_info.reserve_class_name_in_scope @reserve_class_name_in_scope.setter def reserve_class_name_in_scope(self, reserve_class_name_in_scope): - """Sets whether to save the network class name in the scope.""" + """Set whether to save the network class name in the scope.""" self._thread_local_info.reserve_class_name_in_scope = reserve_class_name_in_scope @property @@ -444,7 +444,7 @@ def set_auto_parallel_context(**kwargs): def get_auto_parallel_context(attr_key): """ - Gets auto parallel context attribute value according to the key. + Get auto parallel context attribute value according to the key. Args: attr_key (str): The key of the attribute. @@ -512,7 +512,7 @@ def _check_target_specific_cfgs(device, arg_key): enable_sparse=bool, max_call_depth=int, env_config_path=str) def set_context(**kwargs): """ - Sets context for running environment. + Set context for running environment. Context should be configured before running your program. If there is no configuration, the "Ascend" device target will be used by default. GRAPH_MODE or @@ -679,7 +679,7 @@ def set_context(**kwargs): def get_context(attr_key): """ - Gets context attribute value according to the input key. + Get context attribute value according to the input key. Args: attr_key (str): The key of the attribute. diff --git a/mindspore/dataset/engine/datasets.py b/mindspore/dataset/engine/datasets.py index 7a5274acbf..e4253dc7a0 100644 --- a/mindspore/dataset/engine/datasets.py +++ b/mindspore/dataset/engine/datasets.py @@ -4821,7 +4821,7 @@ class _NumpySlicesDataset: class NumpySlicesDataset(GeneratorDataset): """ - Create a dataset with given data slices, mainly for loading Python data into dataset. + Creates a dataset with given data slices, mainly for loading Python data into dataset. This dataset can take in a sampler. 'sampler' and 'shuffle' are mutually exclusive. The table below shows what input arguments are allowed and their expected behavior. @@ -4920,7 +4920,7 @@ class _PaddedDataset: class PaddedDataset(GeneratorDataset): """ - Create a dataset with filler data provided by user. Mainly used to add to the original data set + Creates a dataset with filler data provided by user. Mainly used to add to the original data set and assign it to the corresponding shard. Args: diff --git a/mindspore/dataset/vision/c_transforms.py b/mindspore/dataset/vision/c_transforms.py index 42a5da9853..74bb97a5ce 100644 --- a/mindspore/dataset/vision/c_transforms.py +++ b/mindspore/dataset/vision/c_transforms.py @@ -162,7 +162,7 @@ class BoundingBoxAugment(ImageTensorOperation): class CenterCrop(ImageTensorOperation): """ - Crops the input image at the center to the given size. + Crop the input image at the center to the given size. Args: size (Union[int, sequence]): The output size of the cropped image. @@ -417,7 +417,7 @@ class NormalizePad(ImageTensorOperation): class Pad(ImageTensorOperation): """ - Pads the image according to padding parameters. + Pad the image according to padding parameters. Args: padding (Union[int, sequence]): The number of pixels to pad the image. diff --git a/mindspore/dataset/vision/py_transforms_util.py b/mindspore/dataset/vision/py_transforms_util.py index 7f4eb66403..e5a8d90c66 100644 --- a/mindspore/dataset/vision/py_transforms_util.py +++ b/mindspore/dataset/vision/py_transforms_util.py @@ -827,7 +827,7 @@ def grayscale(img, num_output_channels): def pad(img, padding, fill_value, padding_mode): """ - Pads the image according to padding parameters. + Pad the image according to padding parameters. Args: img (PIL image): Image to be padded. diff --git a/mindspore/mindrecord/tools/cifar100_to_mr.py b/mindspore/mindrecord/tools/cifar100_to_mr.py index 137171ce5b..a28b3f7897 100644 --- a/mindspore/mindrecord/tools/cifar100_to_mr.py +++ b/mindspore/mindrecord/tools/cifar100_to_mr.py @@ -70,7 +70,7 @@ class Cifar100ToMR: def run(self, fields=None): """ - Executes transformation from cifar100 to MindRecord. + Execute transformation from cifar100 to MindRecord. Args: fields (list[str]): A list of index field, e.g.["fine_label", "coarse_label"]. diff --git a/mindspore/mindrecord/tools/cifar10_to_mr.py b/mindspore/mindrecord/tools/cifar10_to_mr.py index c78293a613..4d17ab0834 100644 --- a/mindspore/mindrecord/tools/cifar10_to_mr.py +++ b/mindspore/mindrecord/tools/cifar10_to_mr.py @@ -70,7 +70,7 @@ class Cifar10ToMR: def run(self, fields=None): """ - Executes transformation from cifar10 to MindRecord. + Execute transformation from cifar10 to MindRecord. Args: fields (list[str], optional): A list of index fields, e.g.["label"] (default=None). diff --git a/mindspore/mindrecord/tools/csv_to_mr.py b/mindspore/mindrecord/tools/csv_to_mr.py index f7cf7d8b1c..19baef9a2a 100644 --- a/mindspore/mindrecord/tools/csv_to_mr.py +++ b/mindspore/mindrecord/tools/csv_to_mr.py @@ -119,7 +119,7 @@ class CsvToMR: def run(self): """ - Executes transformation from csv to MindRecord. + Execute transformation from csv to MindRecord. Returns: MSRStatus, whether csv is successfully transformed to MindRecord. diff --git a/mindspore/mindrecord/tools/imagenet_to_mr.py b/mindspore/mindrecord/tools/imagenet_to_mr.py index 5158377fe6..d7a497a0ad 100644 --- a/mindspore/mindrecord/tools/imagenet_to_mr.py +++ b/mindspore/mindrecord/tools/imagenet_to_mr.py @@ -120,7 +120,7 @@ class ImageNetToMR: def run(self): """ - Executes transformation from imagenet to MindRecord. + Execute transformation from imagenet to MindRecord. Returns: MSRStatus, whether imagenet is successfully transformed to MindRecord. diff --git a/mindspore/mindrecord/tools/mnist_to_mr.py b/mindspore/mindrecord/tools/mnist_to_mr.py index 0419a0df31..aa5e26389d 100644 --- a/mindspore/mindrecord/tools/mnist_to_mr.py +++ b/mindspore/mindrecord/tools/mnist_to_mr.py @@ -123,7 +123,7 @@ class MnistToMR: def _transform_train(self): """ - Executes transformation from Mnist train part to MindRecord. + Execute transformation from Mnist train part to MindRecord. Returns: MSRStatus, whether successfully written into MindRecord. @@ -171,7 +171,7 @@ class MnistToMR: def _transform_test(self): """ - Executes transformation from Mnist test part to MindRecord. + Execute transformation from Mnist test part to MindRecord. Returns: MSRStatus, whether Mnist is successfully transformed to MindRecord. @@ -220,7 +220,7 @@ class MnistToMR: def run(self): """ - Executes transformation from Mnist to MindRecord. + Execute transformation from Mnist to MindRecord. Returns: MSRStatus, whether successfully written into MindRecord. diff --git a/mindspore/nn/dynamic_lr.py b/mindspore/nn/dynamic_lr.py index 0b31b45e06..b5053cecc1 100644 --- a/mindspore/nn/dynamic_lr.py +++ b/mindspore/nn/dynamic_lr.py @@ -75,7 +75,7 @@ def _check_inputs(learning_rate, decay_rate, total_step, step_per_epoch, decay_e def exponential_decay_lr(learning_rate, decay_rate, total_step, step_per_epoch, decay_epoch, is_stair=False): r""" - Calculate learning rate base on exponential decay function. + Calculates learning rate base on exponential decay function. For the i-th step, the formula of computing decayed_learning_rate[i] is: @@ -118,7 +118,7 @@ def exponential_decay_lr(learning_rate, decay_rate, total_step, step_per_epoch, def natural_exp_decay_lr(learning_rate, decay_rate, total_step, step_per_epoch, decay_epoch, is_stair=False): r""" - Calculate learning rate base on natural exponential decay function. + Calculates learning rate base on natural exponential decay function. For the i-th step, the formula of computing decayed_learning_rate[i] is: @@ -162,7 +162,7 @@ def natural_exp_decay_lr(learning_rate, decay_rate, total_step, step_per_epoch, def inverse_decay_lr(learning_rate, decay_rate, total_step, step_per_epoch, decay_epoch, is_stair=False): r""" - Calculate learning rate base on inverse-time decay function. + Calculates learning rate base on inverse-time decay function. For the i-th step, the formula of computing decayed_learning_rate[i] is: @@ -205,7 +205,7 @@ def inverse_decay_lr(learning_rate, decay_rate, total_step, step_per_epoch, deca def cosine_decay_lr(min_lr, max_lr, total_step, step_per_epoch, decay_epoch): r""" - Calculate learning rate base on cosine decay function. + Calculates learning rate base on cosine decay function. For the i-th step, the formula of computing decayed_learning_rate[i] is: @@ -257,7 +257,7 @@ def cosine_decay_lr(min_lr, max_lr, total_step, step_per_epoch, decay_epoch): def polynomial_decay_lr(learning_rate, end_learning_rate, total_step, step_per_epoch, decay_epoch, power, update_decay_epoch=False): r""" - Calculate learning rate base on polynomial decay function. + Calculates learning rate base on polynomial decay function. For the i-th step, the formula of computing decayed_learning_rate[i] is: @@ -332,7 +332,7 @@ def polynomial_decay_lr(learning_rate, end_learning_rate, total_step, step_per_e def warmup_lr(learning_rate, total_step, step_per_epoch, warmup_epoch): r""" - Get learning rate warming up. + Gets learning rate warming up. For the i-th step, the formula of computing warmup_learning_rate[i] is: diff --git a/mindspore/nn/layer/basic.py b/mindspore/nn/layer/basic.py index 5fac61b092..d0c9a73eb8 100644 --- a/mindspore/nn/layer/basic.py +++ b/mindspore/nn/layer/basic.py @@ -38,7 +38,7 @@ __all__ = ['Dropout', 'Flatten', 'Dense', 'ClipByNorm', 'Norm', 'OneHot', 'Pad', class L1Regularizer(Cell): r""" - Apply l1 regularization to weights + Applies l1 regularization to weights. l1 regularization makes weights sparsity @@ -730,7 +730,7 @@ class ResizeBilinear(Cell): class Unfold(Cell): r""" - Extract patches from images. + Extracts patches from images. The input tensor must be a 4-D tensor and the data format is NCHW. Args: diff --git a/mindspore/nn/layer/image.py b/mindspore/nn/layer/image.py index 99945d4f3e..100e4882bf 100644 --- a/mindspore/nn/layer/image.py +++ b/mindspore/nn/layer/image.py @@ -479,7 +479,7 @@ def _get_bbox(rank, shape, central_fraction): class CentralCrop(Cell): """ - Crop the centeral region of the images with the central_fraction. + Crops the centeral region of the images with the central_fraction. Args: central_fraction (float): Fraction of size to crop. It must be float and in range (0.0, 1.0]. diff --git a/mindspore/nn/layer/quant.py b/mindspore/nn/layer/quant.py index ec45802268..e92d2d5a7c 100644 --- a/mindspore/nn/layer/quant.py +++ b/mindspore/nn/layer/quant.py @@ -1148,7 +1148,7 @@ class DenseQuant(Cell): class _QuantActivation(Cell): r""" - Base class for quantization aware training activation function. Add fake quantized operation + Base class for quantization aware training activation function. Adds fake quantized operation after activation operation. """ @@ -1232,7 +1232,7 @@ class ActQuant(_QuantActivation): class TensorAddQuant(Cell): r""" - Add fake quantized operation after TensorAdd operation. + Adds fake quantized operation after TensorAdd operation. This part is a more detailed overview of TensorAdd operation. For more detials about Quantilization, please refer to :class:`mindspore.nn.FakeQuantWithMinMaxObserver`. @@ -1288,7 +1288,7 @@ class TensorAddQuant(Cell): class MulQuant(Cell): r""" - Add fake quantized operation after `Mul` operation. + Adds fake quantized operation after `Mul` operation. This part is a more detailed overview of `Mul` operation. For more detials about Quantilization, please refer to :class:`mindspore.nn.FakeQuantWithMinMaxObserver`. diff --git a/mindspore/nn/metrics/auc.py b/mindspore/nn/metrics/auc.py index cd0155a271..1c93bccd52 100644 --- a/mindspore/nn/metrics/auc.py +++ b/mindspore/nn/metrics/auc.py @@ -18,7 +18,7 @@ import numpy as np def auc(x, y, reorder=False): """ - Compute the Area Under the Curve (AUC) using the trapezoidal rule. This is a general function, given points on a + Computes the Area Under the Curve (AUC) using the trapezoidal rule. This is a general function, given points on a curve. For computing the area under the ROC-curve. Args: diff --git a/mindspore/nn/metrics/bleu_score.py b/mindspore/nn/metrics/bleu_score.py index 7b76c12b39..6407fbb4ee 100644 --- a/mindspore/nn/metrics/bleu_score.py +++ b/mindspore/nn/metrics/bleu_score.py @@ -21,7 +21,7 @@ from .metric import Metric class BleuScore(Metric): """ - Calculate BLEU score of machine translated text with one or more references. + Calculates BLEU score of machine translated text with one or more references. Args: n_gram (int): The n_gram value ranged from 1 to 4. Default: 4 diff --git a/mindspore/nn/metrics/hausdorff_distance.py b/mindspore/nn/metrics/hausdorff_distance.py index 312559f1be..5853a285e8 100644 --- a/mindspore/nn/metrics/hausdorff_distance.py +++ b/mindspore/nn/metrics/hausdorff_distance.py @@ -66,7 +66,7 @@ class _ROISpatialData(metaclass=ABCMeta): class HausdorffDistance(Metric): r""" - Calculate the Hausdorff distance. Hausdorff distance is the maximum and minimum distance between two point sets. + Calculates the Hausdorff distance. Hausdorff distance is the maximum and minimum distance between two point sets. Given two feature sets A and B, the Hausdorff distance between two point sets A and B is defined as follows: .. math:: diff --git a/mindspore/nn/metrics/roc.py b/mindspore/nn/metrics/roc.py index c57ecec8e6..5efba74097 100644 --- a/mindspore/nn/metrics/roc.py +++ b/mindspore/nn/metrics/roc.py @@ -20,7 +20,7 @@ from .metric import Metric class ROC(Metric): """ - Calculate the ROC curve. It is suitable for solving binary classification and multi classification problems. + Calculates the ROC curve. It is suitable for solving binary classification and multi classification problems. In the case of multiclass, the values will be calculated based on a one-vs-the-rest approach. Args: diff --git a/mindspore/numpy/array_ops.py b/mindspore/numpy/array_ops.py index 90537128c3..7f66c3d47a 100644 --- a/mindspore/numpy/array_ops.py +++ b/mindspore/numpy/array_ops.py @@ -1706,7 +1706,7 @@ def flipud(m): def fliplr(m): """ - Flip the entries in each row in the left/right direction. + Flips the entries in each row in the left/right direction. Columns are preserved, but appear in a different order than before. Note: diff --git a/mindspore/ops/operations/inner_ops.py b/mindspore/ops/operations/inner_ops.py index fbfc0a3952..9eb7f5a179 100644 --- a/mindspore/ops/operations/inner_ops.py +++ b/mindspore/ops/operations/inner_ops.py @@ -126,7 +126,7 @@ class Randperm(PrimitiveWithInfer): class NoRepeatNGram(PrimitiveWithInfer): """ - Update log_probs with repeat n-grams. + Updates log_probs with repeat n-grams. During beam search, if consecutive `ngram_size` words exist in the generated word sequence, the consecutive `ngram_size` words will be avoided during subsequent prediction. diff --git a/mindspore/train/callback/_callback.py b/mindspore/train/callback/_callback.py index 6c99bf30fd..d24bd119f3 100644 --- a/mindspore/train/callback/_callback.py +++ b/mindspore/train/callback/_callback.py @@ -227,9 +227,9 @@ class InternalCallbackParam(dict): class RunContext: """ - Provides information about the model. + Provide information about the model. - Provides information about original request to model function. + Provide information about original request to model function. Callback objects can stop the loop by calling request_stop() of run_context. Args: @@ -252,7 +252,7 @@ class RunContext: def request_stop(self): """ - Sets stop requirement during training. + Set stop requirement during training. Callbacks can use this function to request stop of iterations. model.train() checks whether this is called or not. @@ -261,7 +261,7 @@ class RunContext: def get_stop_requested(self): """ - Returns whether a stop is requested or not. + Return whether a stop is requested or not. Returns: bool, if true, model.train() stops iterations. diff --git a/mindspore/train/summary/summary_record.py b/mindspore/train/summary/summary_record.py index c04fac9731..a5c2da7f41 100644 --- a/mindspore/train/summary/summary_record.py +++ b/mindspore/train/summary/summary_record.py @@ -202,7 +202,7 @@ class SummaryRecord: def set_mode(self, mode): """ - Sets the training phase. Different training phases affect data recording. + Set the training phase. Different training phases affect data recording. Args: mode (str): The mode to be set, which should be 'train' or 'eval'. When the mode is 'eval',