From d9c3d6e5b778135d085b7bc0b3391bfddfe5db9b Mon Sep 17 00:00:00 2001 From: wangshuide2020 Date: Wed, 2 Mar 2022 15:40:02 +0800 Subject: [PATCH] fix the documentation of GRU, L2Loss, NLLLoss, etc. --- docs/api/api_python/nn/mindspore.nn.GRU.rst | 2 ++ docs/api/api_python/nn/mindspore.nn.LSTMCell.rst | 2 +- .../api_python/ops/mindspore.ops.ComputeAccidentalHits.rst | 2 +- docs/api/api_python/ops/mindspore.ops.Dropout3D.rst | 2 +- docs/api/api_python/ops/mindspore.ops.L2Loss.rst | 2 +- docs/api/api_python/ops/mindspore.ops.NotEqual.rst | 2 +- mindspore/python/mindspore/ops/operations/array_ops.py | 2 ++ mindspore/python/mindspore/ops/operations/nn_ops.py | 4 ++-- 8 files changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/api/api_python/nn/mindspore.nn.GRU.rst b/docs/api/api_python/nn/mindspore.nn.GRU.rst index cf0db73eb61..b93a1ad24ff 100644 --- a/docs/api/api_python/nn/mindspore.nn.GRU.rst +++ b/docs/api/api_python/nn/mindspore.nn.GRU.rst @@ -17,6 +17,8 @@ mindspore.nn.GRU 其中 :math:`\sigma` 是sigmoid激活函数, :math:`*` 是乘积。 :math:`W,b` 是公式中输出和输入之间的可学习权重。例如, :math:`W_{ir}, b_{ir}` 是用于将输入 :math:`x` 转换为 :math:`r` 的权重和偏置。详见论文 `Learning Phrase Representations using RNN Encoder–Decoder for Statistical Machine Translation `_ 。 + .. note:: 当GRU运行在Ascend上时,hidden size仅支持16的倍数。 + **参数:** - **input_size** (int) - 输入的大小。 diff --git a/docs/api/api_python/nn/mindspore.nn.LSTMCell.rst b/docs/api/api_python/nn/mindspore.nn.LSTMCell.rst index 1212535c317..06e0a82cb5e 100644 --- a/docs/api/api_python/nn/mindspore.nn.LSTMCell.rst +++ b/docs/api/api_python/nn/mindspore.nn.LSTMCell.rst @@ -20,7 +20,7 @@ mindspore.nn.LSTMCell 其中 :math:`\sigma` 是sigmoid函数, :math:`*` 是乘积。 :math:`W,b` 是公式中输出和输入之间的可学习权重。例如,:math:`W_{ix}, b_{ix}` 是用于从输入 :math:`x` 转换为 :math:`i` 的权重和偏置。详见论文 `LONG SHORT-TERM MEMORY `_ 和 `Long Short-Term Memory Recurrent Neural Network Architectures for Large Scale Acoustic Modeling `_ 。 **参数:** - + - **input_size** (int) - 输入的大小。 - **hidden_size** (int)- 隐藏状态大小。 - **has_bias** (bool) - cell是否有偏置 `b_ih` 和 `b_hh` 。默认值:True。 diff --git a/docs/api/api_python/ops/mindspore.ops.ComputeAccidentalHits.rst b/docs/api/api_python/ops/mindspore.ops.ComputeAccidentalHits.rst index 358672f61b2..d6a47d1bfda 100644 --- a/docs/api/api_python/ops/mindspore.ops.ComputeAccidentalHits.rst +++ b/docs/api/api_python/ops/mindspore.ops.ComputeAccidentalHits.rst @@ -9,7 +9,7 @@ **参数:** - - **num_true** (int):每个训练样本的目标类数。默认值:1。 + - **num_true** (int) - 每个训练样本的目标类数。默认值:1。 **输入:** diff --git a/docs/api/api_python/ops/mindspore.ops.Dropout3D.rst b/docs/api/api_python/ops/mindspore.ops.Dropout3D.rst index 845a746f36d..947b6382246 100644 --- a/docs/api/api_python/ops/mindspore.ops.Dropout3D.rst +++ b/docs/api/api_python/ops/mindspore.ops.Dropout3D.rst @@ -13,7 +13,7 @@ **参数:** - - **keep_prob** (float):输入通道保留率,数值范围在0到1之间,例如 `keep_prob` = 0.8,意味着过滤20%的通道。默认值:0.5。 + - **keep_prob** (float) - 输入通道保留率,数值范围在0到1之间,例如 `keep_prob` = 0.8,意味着过滤20%的通道。默认值:0.5。 **输入:** diff --git a/docs/api/api_python/ops/mindspore.ops.L2Loss.rst b/docs/api/api_python/ops/mindspore.ops.L2Loss.rst index 726a5d027cc..65b0d6e9b7b 100644 --- a/docs/api/api_python/ops/mindspore.ops.L2Loss.rst +++ b/docs/api/api_python/ops/mindspore.ops.L2Loss.rst @@ -3,7 +3,7 @@ mindspore.ops.L2Loss .. py:class:: mindspore.ops.L2Loss() - 用于计算L2范数,但不对结果进行开方操作。 + 用于计算L2范数的一半,但不对结果进行开方操作。 把输入设为x,输出设为loss。 diff --git a/docs/api/api_python/ops/mindspore.ops.NotEqual.rst b/docs/api/api_python/ops/mindspore.ops.NotEqual.rst index f999e414eb0..f46f6327034 100644 --- a/docs/api/api_python/ops/mindspore.ops.NotEqual.rst +++ b/docs/api/api_python/ops/mindspore.ops.NotEqual.rst @@ -30,4 +30,4 @@ mindspore.ops.NotEqual **异常:** - **TypeError** - `x` 和 `y` 不是以下之一:Tensor、Number、bool。 - - **TypeError** - `x` 和 `y` 都不是Tensor。 \ No newline at end of file + - **TypeError** - `x` 和 `y` 都不是Tensor。 diff --git a/mindspore/python/mindspore/ops/operations/array_ops.py b/mindspore/python/mindspore/ops/operations/array_ops.py index 57f9297a91e..c8aeb459c51 100755 --- a/mindspore/python/mindspore/ops/operations/array_ops.py +++ b/mindspore/python/mindspore/ops/operations/array_ops.py @@ -1852,6 +1852,7 @@ class ArgMaxWithValue(PrimitiveWithInfer): Outputs: tuple (Tensor), tuple of 2 tensors, containing the corresponding index and the maximum value of the input tensor. + - index (Tensor) - The index for the maximum value of the input tensor. If `keep_dims` is true, the shape of output tensors is :math:`(x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)`. Otherwise, the shape is :math:`(x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)`. @@ -1920,6 +1921,7 @@ class ArgMinWithValue(PrimitiveWithInfer): Outputs: tuple (Tensor), tuple of 2 tensors, containing the corresponding index and the minimum value of the input tensor. + - index (Tensor) - The index for the minimum value of the input tensor. If `keep_dims` is true, the shape of output tensors is :math:`(x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)`. Otherwise, the shape is :math:`(x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)`. diff --git a/mindspore/python/mindspore/ops/operations/nn_ops.py b/mindspore/python/mindspore/ops/operations/nn_ops.py index 520ca09087c..38d98b7d4a4 100644 --- a/mindspore/python/mindspore/ops/operations/nn_ops.py +++ b/mindspore/python/mindspore/ops/operations/nn_ops.py @@ -2337,7 +2337,7 @@ class SparseSoftmaxCrossEntropyWithLogits(PrimitiveWithInfer): .. math:: \begin{array}{ll} \\ p_{ij} = softmax(X_{ij}) = \frac{\exp(x_i)}{\sum_{j = 0}^{N-1}\exp(x_j)} \\ - loss_{ij} = \begin{cases} -ln(p_{ij}), &j = y_i \cr -ln(1 - p_{ij}), & j \neq y_i \end{cases} \\ + loss_{ij} = \begin{cases} -ln(p_{ij}), &j = y_i \cr 0, & j \neq y_i \end{cases} \\ loss = \sum_{ij} loss_{ij} \end{array} @@ -2601,7 +2601,7 @@ class SoftMarginLoss(Primitive): class L2Loss(Primitive): r""" - Calculates the L2 norm, but do not square the result. + Calculates half of the L2 norm, but do not square the result. Set input as x and output as loss.