From 5b5cfee0b193ce172f0110954b7b6ece988e7c54 Mon Sep 17 00:00:00 2001 From: zhangyi Date: Thu, 7 Jan 2021 17:13:31 +0800 Subject: [PATCH] fix some api comments. --- mindspore/common/initializer.py | 2 +- mindspore/common/tensor.py | 4 ++-- mindspore/dataset/transforms/c_transforms.py | 2 +- mindspore/nn/layer/conv.py | 2 +- mindspore/nn/layer/embedding.py | 6 +++--- mindspore/nn/optim/momentum.py | 2 ++ mindspore/nn/optim/sgd.py | 2 ++ mindspore/nn/probability/bijector/softplus.py | 1 + mindspore/nn/probability/distribution/bernoulli.py | 2 -- mindspore/nn/probability/distribution/exponential.py | 2 -- 10 files changed, 13 insertions(+), 12 deletions(-) diff --git a/mindspore/common/initializer.py b/mindspore/common/initializer.py index 77610e15a2..d3b186e02a 100644 --- a/mindspore/common/initializer.py +++ b/mindspore/common/initializer.py @@ -259,7 +259,7 @@ class HeUniform(Initializer): Initialize the array with He kaiming uniform algorithm, and from a uniform distribution collect samples within U[-boundary, boundary] The boundary is defined as : - where :math:`boundary = \sqrt{\frac{6}{(1 + a^2) \times \text{fan\_in}}}`. + where :math:`boundary = \sqrt{\frac{6}{(1 + a^2) \times \text{fan_in}}}`. Args: negative_slope (int, float, bool): Default: 0, used when nonlinearity is 'leaky_relu'. diff --git a/mindspore/common/tensor.py b/mindspore/common/tensor.py index 07dc7d462f..679b334ed6 100644 --- a/mindspore/common/tensor.py +++ b/mindspore/common/tensor.py @@ -391,8 +391,8 @@ class Tensor(Tensor_): Args: slice_index (int): Slice index of a parameter's slices. - It is used when initialize a slice of a parameter, it guarantees that devices - using the same slice can generate the same tensor. + It is used when initialize a slice of a parameter, it guarantees that devices + using the same slice can generate the same tensor. shape (list[int]): Shape of the slice, it is used when initialize a slice of the parameter. opt_shard_group(str): Optimizer shard group which is used in auto or semi auto parallel mode to get one shard of a parameter's slice. diff --git a/mindspore/dataset/transforms/c_transforms.py b/mindspore/dataset/transforms/c_transforms.py index f2c1bd08af..92cbd2ae32 100644 --- a/mindspore/dataset/transforms/c_transforms.py +++ b/mindspore/dataset/transforms/c_transforms.py @@ -136,7 +136,7 @@ class Slice(cde.SliceOp): 1. :py:obj:`int`: Slice this index only along the first dimension. Negative index is supported. 2. :py:obj:`list(int)`: Slice these indices along the first dimension. Negative indices are supported. 3. :py:obj:`slice`: Slice the generated indices from the slice object along the first dimension. - Similar to `start:stop:step`. + Similar to `start:stop:step`. 4. :py:obj:`None`: Slice the whole dimension. Similar to `:` in Python indexing. 5. :py:obj:`Ellipses`: Slice the whole dimension. Similar to `:` in Python indexing. diff --git a/mindspore/nn/layer/conv.py b/mindspore/nn/layer/conv.py index 7a80b2fae6..f447dc6f81 100644 --- a/mindspore/nn/layer/conv.py +++ b/mindspore/nn/layer/conv.py @@ -191,7 +191,7 @@ class Conv2d(_Conv): Inputs: - **input** (Tensor) - Tensor of shape :math:`(N, C_{in}, H_{in}, W_{in})` \ - or `(N, H_{in}, W_{in}, C_{in})`. + or `(N, H_{in}, W_{in}, C_{in})`. Outputs: Tensor of shape :math:`(N, C_{out}, H_{out}, W_{out})` or `(N, H_{out}, W_{out}, C_{out})`. diff --git a/mindspore/nn/layer/embedding.py b/mindspore/nn/layer/embedding.py index c19816ea74..79052e8541 100755 --- a/mindspore/nn/layer/embedding.py +++ b/mindspore/nn/layer/embedding.py @@ -365,13 +365,13 @@ class MultiFieldEmbeddingLookup(EmbeddingLookup): operator (string): The pooling method for the features in one field. Support 'SUM, 'MEAN' and 'MAX' Inputs: - - **input_indices** (Tensor) - The shape of tensor is :math:`(batch_size, seq_length)`. + - **input_indices** (Tensor) - The shape of tensor is :math:`(batch\_size, seq\_length)`. Specifies the indices of elements of the original Tensor. Input_indices must be a 2d tensor in this interface. Type is Int32, Int64. - - **input_values** (Tensor) - The shape of tensor is :math:`(batch_size, seq_length)`. + - **input_values** (Tensor) - The shape of tensor is :math:`(batch\_size, seq\_length)`. Specifies the weights of elements of the input_indices. The lookout vector will multiply with the input_values. Type is Float32. - - **field_ids** (Tensor) - The shape of tensor is :math:`(batch_size, seq_length)`. + - **field_ids** (Tensor) - The shape of tensor is :math:`(batch\_size, seq\_length)`. Specifies the field id of elements of the input_indices. Type is Int32. Outputs: diff --git a/mindspore/nn/optim/momentum.py b/mindspore/nn/optim/momentum.py index 0b73d5c0c8..8994331ad7 100755 --- a/mindspore/nn/optim/momentum.py +++ b/mindspore/nn/optim/momentum.py @@ -56,10 +56,12 @@ class Momentum(Optimizer): v_{t} = v_{t-1} \ast u + gradients If use_nesterov is True: + .. math:: p_{t} = p_{t-1} - (grad \ast lr + v_{t} \ast u \ast lr) If use_nesterov is Flase: + .. math:: p_{t} = p_{t-1} - lr \ast v_{t} diff --git a/mindspore/nn/optim/sgd.py b/mindspore/nn/optim/sgd.py index 2075d3c74d..81d0e39676 100755 --- a/mindspore/nn/optim/sgd.py +++ b/mindspore/nn/optim/sgd.py @@ -50,10 +50,12 @@ class SGD(Optimizer): v_{t+1} = u \ast v_{t} + gradient \ast (1-dampening) If nesterov is True: + .. math:: p_{t+1} = p_{t} - lr \ast (gradient + u \ast v_{t+1}) If nesterov is Flase: + .. math:: p_{t+1} = p_{t} - lr \ast v_{t+1} diff --git a/mindspore/nn/probability/bijector/softplus.py b/mindspore/nn/probability/bijector/softplus.py index b01f0e71fb..7955b3a849 100644 --- a/mindspore/nn/probability/bijector/softplus.py +++ b/mindspore/nn/probability/bijector/softplus.py @@ -27,6 +27,7 @@ class Softplus(Bijector): .. math:: Y = \frac{\log(1 + e ^ {kX})}{k} + where k is the sharpness factor. Args: diff --git a/mindspore/nn/probability/distribution/bernoulli.py b/mindspore/nn/probability/distribution/bernoulli.py index f3281d9bda..8af81a0de6 100644 --- a/mindspore/nn/probability/distribution/bernoulli.py +++ b/mindspore/nn/probability/distribution/bernoulli.py @@ -49,12 +49,10 @@ class Bernoulli(Distribution): >>> # A Bernoulli distribution can be initialized without arguments. >>> # In this case, `probs` must be passed in through arguments during function calls. >>> b2 = msd.Bernoulli(dtype=mindspore.int32) - >>> # Here are some tensors used below for testing >>> value = Tensor([1, 0, 1], dtype=mindspore.int32) >>> probs_a = Tensor([0.6], dtype=mindspore.float32) >>> probs_b = Tensor([0.2, 0.3, 0.4], dtype=mindspore.float32) - >>> # Private interfaces of probability functions corresponding to public interfaces, including >>> # `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival`, are the same as follows. >>> # Args: diff --git a/mindspore/nn/probability/distribution/exponential.py b/mindspore/nn/probability/distribution/exponential.py index 3a1cab7ca4..f5e90d7d99 100644 --- a/mindspore/nn/probability/distribution/exponential.py +++ b/mindspore/nn/probability/distribution/exponential.py @@ -51,12 +51,10 @@ class Exponential(Distribution): >>> # An Exponential distribution can be initialized without arguments. >>> # In this case, `rate` must be passed in through `args` during function calls. >>> e2 = msd.Exponential(dtype=mindspore.float32) - >>> # Here are some tensors used below for testing >>> value = Tensor([1, 2, 3], dtype=mindspore.float32) >>> rate_a = Tensor([0.6], dtype=mindspore.float32) >>> rate_b = Tensor([0.2, 0.5, 0.4], dtype=mindspore.float32) - >>> # Private interfaces of probability functions corresponding to public interfaces, including >>> # `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival`, are the same as follows. >>> # Args: