diff --git a/docs/api/api_python/nn/mindspore.nn.ClipByNorm.rst b/docs/api/api_python/nn/mindspore.nn.ClipByNorm.rst index d078208247f..1a15abcbe91 100644 --- a/docs/api/api_python/nn/mindspore.nn.ClipByNorm.rst +++ b/docs/api/api_python/nn/mindspore.nn.ClipByNorm.rst @@ -20,7 +20,7 @@ mindspore.nn.ClipByNorm **输入:** - **x** (Tensor) - 输入n维的Tensor,数据类型为float32或float16。 - - **clip_norm** (Tensor) - shape为 :math:`()` 或 :math:`(1)` 的Tensor。或者Tensor的shape可以广播到输入的shape。 + - **clip_norm** (Tensor) - shape为 :math:`()` 或 :math:`(1)` 的Tensor。或者其shape可以广播到输入的shape。 **输出:** diff --git a/docs/api/api_python/nn/mindspore.nn.Dropout.rst b/docs/api/api_python/nn/mindspore.nn.Dropout.rst index 45a295fa0d3..91885b83871 100644 --- a/docs/api/api_python/nn/mindspore.nn.Dropout.rst +++ b/docs/api/api_python/nn/mindspore.nn.Dropout.rst @@ -14,7 +14,7 @@ mindspore.nn.Dropout **参数:** - - **keep_prob** (float) - 输入神经元保留率,数值范围在0到1之间。例如,rate=0.9,删除10%的输入单位。默认值:0.5。 + - **keep_prob** (float) - 输入神经元保留率,数值范围在0到1之间。例如,rate=0.9,删除10%的神经元。默认值:0.5。 - **dtype** (:class:`mindspore.dtype`) - `x` 的数据类型。默认值:float32。 **输入:** diff --git a/docs/api/api_python/nn/mindspore.nn.GRUCell.rst b/docs/api/api_python/nn/mindspore.nn.GRUCell.rst index 84584687078..a26f729439f 100644 --- a/docs/api/api_python/nn/mindspore.nn.GRUCell.rst +++ b/docs/api/api_python/nn/mindspore.nn.GRUCell.rst @@ -20,7 +20,7 @@ mindspore.nn.GRUCell - **input_size** (int) - 输入的大小。 - **hidden_size** (int) - 隐藏状态大小。 - - **has_bias** (bool) - cell是否有偏置项 `b_ih` 和 `b_hh` 。默认值:True。 + - **has_bias** (bool) - cell是否有偏置项 `b_in` 和 `b_hn` 。默认值:True。 **输入:** diff --git a/docs/api/api_python/nn/mindspore.nn.LSTMCell.rst b/docs/api/api_python/nn/mindspore.nn.LSTMCell.rst index 06e0a82cb5e..ace1805167b 100644 --- a/docs/api/api_python/nn/mindspore.nn.LSTMCell.rst +++ b/docs/api/api_python/nn/mindspore.nn.LSTMCell.rst @@ -19,6 +19,11 @@ 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 `_ 。 + nn层封装的LSTMCell可以简化为如下公式: + + .. math:: + h^{'},c^{'} = LSTMCell(x, (h_0, c_0)) + **参数:** - **input_size** (int) - 输入的大小。 diff --git a/docs/api/api_python/nn/mindspore.nn.LayerNorm.rst b/docs/api/api_python/nn/mindspore.nn.LayerNorm.rst index c916aa95a33..9e59759c876 100644 --- a/docs/api/api_python/nn/mindspore.nn.LayerNorm.rst +++ b/docs/api/api_python/nn/mindspore.nn.LayerNorm.rst @@ -8,7 +8,7 @@ mindspore.nn.LayerNorm 层归一化在递归神经网络中被广泛的应用。适用单个训练用例的mini-batch输入上应用归一化,详见论文 `Layer Normalization `_ 。 与批归一化(Batch Normalization)不同,层归一化在训练和测试时执行完全相同的计算。 - 应用于所有通道和像素,即使只有一个batch size也能应用。公式如下: + 应用于所有通道和像素,即使batch_size=1也适用。公式如下: .. math:: y = \frac{x - \mathrm{E}[x]}{\sqrt{\mathrm{Var}[x] + \epsilon}} * \gamma + \beta @@ -16,7 +16,7 @@ mindspore.nn.LayerNorm **参数:** - **normalized_shape** (Union(tuple[int], list[int]) - 沿轴 `begin_norm_axis ... R - 1` 执行归一化。 - - **begin_norm_axis** (int) - 第一个归一化维度:归一化将在维度 `begin_norm_axis: rank(inputs)` 上执行,取值范围是[-1, rank(input))。默认值:-1。 + - **begin_norm_axis** (int) - 归一化开始计算的轴:归一化将在维度 `begin_norm_axis: rank(inputs)` 上执行,取值范围是[-1, rank(input))。默认值:-1。 - **begin_params_axis** (int) - 第一个参数(beta, gamma)的维度:scale和centering参数有 `begin_params_axis: rank(inputs)` 个维度,并与输入一起广播,取值范围是[-1, rank(input))。默认值:-1。 - **gamma_init** (Union[Tensor, str, Initializer, numbers.Number]) - gama参数的初始化方法。str的值引用自函数 `initializer` ,包括'zeros'、'ones'、'xavier_uniform'、'he_uniform'等。默认值:'ones'。 - **beta_init** (Union[Tensor, str, Initializer, numbers.Number]) - beta参数的初始化方法。str的值引用自函数 `initializer` ,包括'zeros'、'ones'、'xavier_uniform'、'he_uniform'等。默认值:'zeros'。 @@ -24,7 +24,7 @@ mindspore.nn.LayerNorm **输入:** - - **x** (Tensor) - 'x'的shape为 :math:`(x_1, x_2, ..., x_R)` , `input_shape[begin_norm_axis:]` 等于 `normalized_shape` 。 + - **x** (Tensor) - `x` 的shape为 :math:`(x_1, x_2, ..., x_R)` , `input_shape[begin_norm_axis:]` 等于 `normalized_shape` 。 **输出:** @@ -32,6 +32,6 @@ mindspore.nn.LayerNorm **异常:** - - **TypeError** - `normalized_shape` 既不是列表也不是元组。 - - **TypeError** - `begin_norm_axis` 或 `begin_params_axis` 不是整数。 + - **TypeError** - `normalized_shape` 既不是list也不是tuple。 + - **TypeError** - `begin_norm_axis` 或 `begin_params_axis` 不是int。 - **TypeError** - `epsilon` 不是float。 \ No newline at end of file diff --git a/docs/api/api_python/nn/mindspore.nn.PReLU.rst b/docs/api/api_python/nn/mindspore.nn.PReLU.rst index ce9c65c3a36..c87bc9ba4f3 100644 --- a/docs/api/api_python/nn/mindspore.nn.PReLU.rst +++ b/docs/api/api_python/nn/mindspore.nn.PReLU.rst @@ -9,7 +9,7 @@ mindspore.nn.PReLU .. math:: - prelu(x_i)= \max(0, x_i) + w * \min(0, x_i), + PReLU(x_i)= \max(0, x_i) + w * \min(0, x_i), 其中 :math:`x_i` 是输入的Tensor。 @@ -17,12 +17,12 @@ mindspore.nn.PReLU 当带参数调用时每个通道上学习一个 :math:`w` 。如果不带参数调用时,则将在所有通道中共享单个参数 :math:`w` 。 - ReLU相关图参见 `PReLU `_ 。 + PReLU相关图参见 `PReLU `_ 。 **参数:** - **channel** (int) - 可训练参数 :math:`w` 的数量。它可以是int,值是1或输入Tensor `x` 的通道数。默认值:1。 - - **w** (Union[float, list, Tensor]) - 参数的初始值。它可以是float、float list或与输入Tensor `x` 具有相同数据类型的Tensor。默认值:0.25。 + - **w** (Union[float, list, Tensor]) - 参数的初始值。它可以是float、float组成的list或与输入Tensor `x` 具有相同数据类型的Tensor。默认值:0.25。 **输入:** @@ -34,8 +34,8 @@ mindspore.nn.PReLU **异常:** - - **TypeError** - `channel` 不是整数。 - - **TypeError** - `w` 不是float、float list或float Tensor。 + - **TypeError** - `channel` 不是int。 + - **TypeError** - `w` 不是float、float组成的list或float Tensor。 - **TypeError** - `x` 的数据类型既不是float16也不是float32。 - **ValueError** - `x` 是Ascend上的0-D或1-D Tensor。 - **ValueError** - `channel` 小于1。 \ No newline at end of file diff --git a/docs/api/api_python/nn/mindspore.nn.Pad.rst b/docs/api/api_python/nn/mindspore.nn.Pad.rst index d20eb7c8280..d8fa36fb0ee 100644 --- a/docs/api/api_python/nn/mindspore.nn.Pad.rst +++ b/docs/api/api_python/nn/mindspore.nn.Pad.rst @@ -7,7 +7,7 @@ mindspore.nn.Pad **参数:** - - **paddings** (tuple) - 填充大小,其shape为(N, 2),N是输入数据的维度,填充的元素为int类型。对于 `x` 的第 `D` 个维度,paddings[D, 0]表示要在输入Tensor的第 `D` 个维度之前扩展的大小,paddings[D, 1]表示在输入Tensor的第 `D` 个维度后面要扩展的大小。输出的每个维度D的填充大小为: :math:`paddings[D, 0] + input\_x.dim\_size(D) + paddings[D, 1]` + - **paddings** (tuple) - 填充大小,其shape为(N, 2),N是输入数据的维度,填充的元素为int类型。对于 `x` 的第 `D` 个维度,paddings[D, 0]表示要在输入Tensor的第 `D` 个维度之前扩展的大小,paddings[D, 1]表示在输入Tensor的第 `D` 个维度后面要扩展的大小。每个维度填充后的大小为: :math:`paddings[D, 0] + input\_x.dim\_size(D) + paddings[D, 1]` .. code-block:: @@ -38,5 +38,5 @@ mindspore.nn.Pad **异常:** - **TypeError** - `paddings` 不是tuple。 - - **ValueError** - `paddings` 的长度超过4或其shape不是(n, 2)。 + - **ValueError** - `paddings` 的长度超过4或其shape不是(N, 2)。 - **ValueError** - `mode` 不是'CONSTANT','REFLECT'或'SYMMETRIC'。 \ No newline at end of file diff --git a/docs/api/api_python/nn/mindspore.nn.RMSELoss.rst b/docs/api/api_python/nn/mindspore.nn.RMSELoss.rst index 207daa8024e..62bcaed30cd 100644 --- a/docs/api/api_python/nn/mindspore.nn.RMSELoss.rst +++ b/docs/api/api_python/nn/mindspore.nn.RMSELoss.rst @@ -12,9 +12,9 @@ mindspore.nn.RMSELoss **输入:** - - **logits** (Tensor) - 输入的预测值,任意维度的Tensor。 - - **labels** (Tensor) - 输入的目标值,任意维度的Tensor。一般与 `logits` 的shape相同。如果 `logits` 和 `labels` 的shape不同,需支持广播。 + - **logits** (Tensor) - 输入的预测值,任意维度的Tensor。 + - **labels** (Tensor) - 输入的目标值,任意维度的Tensor。一般与 `logits` 的shape相同。如果 `logits` 和 `labels` 的shape不同,需支持广播。 **输出:** - Tensor,输出值为加权损失值,其数据类型为float,其shape为0。 \ No newline at end of file + Tensor,输出值为加权损失值,其数据类型为float,其shape为()。 \ No newline at end of file diff --git a/docs/api/api_python/nn/mindspore.nn.RNN.rst b/docs/api/api_python/nn/mindspore.nn.RNN.rst index 112ec66dd2f..8b1b6af632e 100644 --- a/docs/api/api_python/nn/mindspore.nn.RNN.rst +++ b/docs/api/api_python/nn/mindspore.nn.RNN.rst @@ -10,7 +10,7 @@ mindspore.nn.RNN .. math:: h_t = \tanh(W_{ih} x_t + b_{ih} + W_{hh} h_{(t-1)} + b_{hh}) - 这里的 :math:`h_t` 是在 `t` 时刻的隐藏状态, :math:`x_t`是在 `t` 时刻的输入, :math:`h_{(t-1)}` 是上一层在 `t-1` 时刻的隐藏状态,或在 `0` 时刻的初始隐藏状态。如果 ``nonlinearity`` 是'relu',则使用 :math:`\text{ReLU}` 而不是 :math:`\tanh` 。 + 这里的 :math:`h_t` 是在 `t` 时刻的隐藏状态, :math:`x_t`是在 `t` 时刻的输入, :math:`h_{(t-1)}` 是上一层在 :math:`t-1` 时刻的隐藏状态,或初始隐藏状态。如果 `nonlinearity` 是'relu',则使用 :math:`\text{relu}` 而不是 :math:`\tanh` 。 **参数:** @@ -27,11 +27,11 @@ mindspore.nn.RNN - **x** (Tensor) - 数据类型为mindspore.float32或mindspore.float16,shape为(seq_len, batch_size, `input_size`)或(batch_size, seq_len, `input_size`)的Tensor。 - **hx** (Tensor) - 数据类型为mindspore.float32或mindspore.float16,shape为(num_directions * `num_layers`, batch_size, `hidden_size`)的Tensor。 `hx` 的数据类型与 `x` 相同。 - - **seq_length** (Tensor) - 输入batch的序列长度,Tensor的shape为 :math:`(\text{batch_size})` 。此输入指明真实的序列长度,以避免使用填充后的元素计算隐藏状态,影响最后的输出。当**x**被填充元素时,建议使用此输入。默认值:None。 + - **seq_length** (Tensor) - 输入batch的序列长度,Tensor的shape为 `(batch_size)` 。此输入指明真实的序列长度,以避免使用填充后的元素计算隐藏状态,影响最后的输出。当**x**被填充元素时,建议使用此输入。默认值:None。 **输出:** - Tuple,包含(`output`, `h_n`)的tuple。 + Tuple,包含(`output`, `hx_n`)的tuple。 - **output** (Tensor) - shape为(seq_len, batch_size, num_directions * `hidden_size`)或(batch_size, seq_len, num_directions * `hidden_size`)的Tensor。 - **hx_n** (Tensor) - shape为(num_directions * `num_layers` , batch_size, `hidden_size`)的Tensor。 diff --git a/docs/api/api_python/nn/mindspore.nn.RNNCell.rst b/docs/api/api_python/nn/mindspore.nn.RNNCell.rst index d3ee36ffb0c..7147ec0cc65 100644 --- a/docs/api/api_python/nn/mindspore.nn.RNNCell.rst +++ b/docs/api/api_python/nn/mindspore.nn.RNNCell.rst @@ -8,7 +8,7 @@ mindspore.nn.RNNCell .. math:: h_t = \tanh(W_{ih} x_t + b_{ih} + W_{hh} h_{(t-1)} + b_{hh}) - 其中 :math:`h_t` 是在 `t` 时刻的隐藏状态, :math:`x_t` 是在 `t` 时刻的输入, :math:`h_{(t-1)}` 是在 `t-1` 时刻的隐藏状态,或在 `0` 时刻的初始隐藏状态。 + 其中 :math:`h_t` 是在 `t` 时刻的隐藏状态, :math:`x_t` 是在 `t` 时刻的输入, :math:`h_{(t-1)}` 是在 :math:`t-1` 时刻的隐藏状态,或初始隐藏状态。 如果 `nonlinearity` 是'relu',则使用'relu'而不是'tanh'。 diff --git a/docs/api/api_python/nn/mindspore.nn.ReLU6.rst b/docs/api/api_python/nn/mindspore.nn.ReLU6.rst index b5b7bf6ece0..2db0225c1fa 100644 --- a/docs/api/api_python/nn/mindspore.nn.ReLU6.rst +++ b/docs/api/api_python/nn/mindspore.nn.ReLU6.rst @@ -8,11 +8,11 @@ mindspore.nn.ReLU6 ReLU6类似于ReLU,不同之处在于设置了上限,其上限为6,如果输入大于6,输出会被限制为6。公式如下: .. math:: - \min(\max(0, x), 6). + Y = \min(\max(0, x), 6). **输入:** - - **x** (Tensor) - ReLU6的输入,任意维度的Tensor,其数据类型为float16或float32的。 + - **x** (Tensor) - ReLU6的输入,任意维度的Tensor,其数据类型为float16或float32。 **输出:** diff --git a/docs/api/api_python/nn/mindspore.nn.ResizeBilinear.rst b/docs/api/api_python/nn/mindspore.nn.ResizeBilinear.rst index dffca4d054f..b6b5ae9ec49 100644 --- a/docs/api/api_python/nn/mindspore.nn.ResizeBilinear.rst +++ b/docs/api/api_python/nn/mindspore.nn.ResizeBilinear.rst @@ -7,14 +7,14 @@ mindspore.nn.ResizeBilinear **参数:** - - **half_pixel_centers** (bool) - 是否几何中心对齐。如果设置为True, 那么 `scale_factor` 应该设置为False。默认值:False。 + - **half_pixel_centers** (bool) - 是否几何中心对齐。如果设置为True, 那么 `align_corners` 应该设置为False。默认值:False。 **输入:** - **x** (Tensor) - ResizeBilinear的输入,四维的Tensor,其shape为 :math:`(batch, channels, height, width)` ,数据类型为float16或float32。 - - **size** (Union[tuple[int], list[int], None]) - 指定新Tensor的大小,其shape为 :math:`(new\_height, new\_width)` 的tuple或者list。只有size或scale_factor能设置为None。默认值:None。 - - **scale_factor** (int, None) - 新Tensor大小的缩放因子,其值为正整数。只有size或scale_factor能设置为None。默认值:None。 - - **align_corners** (bool) - 如果为True,将使用 :math:`(new\_height - 1) / (height - 1)` 来调整输入,这将精确对齐图像的4个角以及调整图像大小。如果为False,将使用 :math:`new\_height / height` 来调整。默认值:False。 + - **size** (Union[tuple[int], list[int], None]) - 指定新Tensor的shape大小,其shape为 :math:`(new\_height, new\_width)` 的tuple或者list。只有size或scale_factor能设置为None。默认值:None。 + - **scale_factor** (int, None) - 新Tensor大小的缩放因子,其值为正整数。 `size` 或 `scale_factor` 有且只有一个能设置为None。默认值:None。 + - **align_corners** (bool) - 如果为True,将使用 :math:`(new\_height - 1) / (height - 1)` 来调整输入,这将精确对齐图像的4个角以及调整图像尺寸。如果为False,将使用 :math:`new\_height / height` 来调整。默认值:False。 **输出:** diff --git a/docs/api/api_python/nn/mindspore.nn.SampledSoftmaxLoss.rst b/docs/api/api_python/nn/mindspore.nn.SampledSoftmaxLoss.rst index bc268ad1ae9..9090aa7be5a 100644 --- a/docs/api/api_python/nn/mindspore.nn.SampledSoftmaxLoss.rst +++ b/docs/api/api_python/nn/mindspore.nn.SampledSoftmaxLoss.rst @@ -5,7 +5,7 @@ mindspore.nn.SampledSoftmaxLoss 抽样交叉熵损失函数。 - 一般在类别数很大时使用,可加速训练交叉熵分类器。 + 一般在类别数很大时使用,可加速训练以交叉熵为损失函数的分类器。 **参数:** diff --git a/docs/api/api_python/nn/mindspore.nn.SoftMarginLoss.rst b/docs/api/api_python/nn/mindspore.nn.SoftMarginLoss.rst index e501ebe0f94..b1f7e6c43d8 100644 --- a/docs/api/api_python/nn/mindspore.nn.SoftMarginLoss.rst +++ b/docs/api/api_python/nn/mindspore.nn.SoftMarginLoss.rst @@ -10,6 +10,8 @@ mindspore.nn.SoftMarginLoss .. math:: \text{loss}(x, y) = \sum_i \frac{\log(1 + \exp(-y[i]*x[i]))}{\text{x.nelement}()} + :math:`x.nelement()` 代表 `x` 中元素的个数。 + **参数:** - **reduction** (str) - 指定应用于输出结果的计算方式。取值为"mean","sum",或"none"。默认值:"mean"。 @@ -21,7 +23,7 @@ mindspore.nn.SoftMarginLoss **输出:** - Tensor或Scalar,如果 `reduction` 为"none",其shape与 `logits` 相同。否则,将返回scalar。 + Tensor或Scalar,如果 `reduction` 为"none",其shape与 `logits` 相同。否则,将返回Scalar。 **异常:** diff --git a/docs/api/api_python/nn/mindspore.nn.Triu.rst b/docs/api/api_python/nn/mindspore.nn.Triu.rst index c41e0af8dd3..4459c533fc9 100644 --- a/docs/api/api_python/nn/mindspore.nn.Triu.rst +++ b/docs/api/api_python/nn/mindspore.nn.Triu.rst @@ -13,7 +13,7 @@ mindspore.nn.Triu **输入:** - **x** (Tensor) - Triu的输入,任意维度的Tensor,其数据类型为Number。 - - **k** (Int) - 对角线的索引。默认值:0。 + - **k** (int) - 对角线的索引。默认值:0。 **输出:** diff --git a/docs/api/api_python/nn/mindspore.nn.Unfold.rst b/docs/api/api_python/nn/mindspore.nn.Unfold.rst index 572a7f038f8..5fcb0eb4298 100644 --- a/docs/api/api_python/nn/mindspore.nn.Unfold.rst +++ b/docs/api/api_python/nn/mindspore.nn.Unfold.rst @@ -5,13 +5,13 @@ mindspore.nn.Unfold 从图像中提取滑窗的区域块。 - 输入为一个四维的Tensor,数据格式为NCHW。 + 输入为一个四维的Tensor,数据格式为(N, C, H, W)。 **参数:** - - **ksizes** (Union[tuple[int], list[int]]):滑窗大小,其格式为[1, ksize_row, ksize_col, 1]的tuple或int列表。 - - **strides** (Union[tuple[int], list[int]]):滑窗步长,其格式为[1, stride_row, stride_col, 1]的tuple或int列表。 - - **rates** (Union[tuple[int], list[int]]):滑窗元素之间的空洞个数,其格式为[1, rate_row, rate_col, 1] 的tuple或整数list。 + - **ksizes** (Union[tuple[int], list[int]]):滑窗大小,其格式为[1, ksize_row, ksize_col, 1]的int组成的tuple或list。 + - **strides** (Union[tuple[int], list[int]]):滑窗步长,其格式为[1, stride_row, stride_col, 1]的int组成的tuple或list。 + - **rates** (Union[tuple[int], list[int]]):滑窗元素之间的空洞个数,其格式为[1, rate_row, rate_col, 1] 的int组成的tuple或list。 - **padding** (str):填充模式,可选值有:"same"或"valid"的字符串,不区分大小写。默认值:"valid"。 - **same** - 指所提取的区域块的部分区域可以在原始图像之外,此部分填充为0。 @@ -19,11 +19,11 @@ mindspore.nn.Unfold **输入:** - - **x** (Tensor) - 输入四维Tensor, 其shape为[in_batch, in_depth, in_row, in_col],其数据类型为number。 + - **x** (Tensor) - 输入四维Tensor, 其shape为[in_batch, in_depth, in_row, in_col],其数据类型为int。 **输出:** - Tensor,输出为四维Tensor,数据类型与 `x` 相同,其shape为[out_batch, out_depth, out_row, out_col],且 `out_batch` 与 `in_batch` 相同。 + Tensor,输出为四维Tensor,数据类型与 `x` 相同,其shape为(out_batch, out_depth, out_row, out_col),且 `out_batch` 与 `in_batch` 相同。 :math:`out\_depth = ksize\_row * ksize\_col * in\_depth` diff --git a/docs/api/api_python/ops/mindspore.ops.AllGather.rst b/docs/api/api_python/ops/mindspore.ops.AllGather.rst index b86fdd795a8..18300a527c2 100644 --- a/docs/api/api_python/ops/mindspore.ops.AllGather.rst +++ b/docs/api/api_python/ops/mindspore.ops.AllGather.rst @@ -6,7 +6,7 @@ 在指定的通信组中汇聚Tensor。 .. note:: - 集合中所有进程的Tensor拥有相同的shape和格式。用户在使用之前需要设置环境变量,运行下面的例子。获取详情请点击官方网站 `MindSpore `_ 。 + 集合中所有进程的Tensor必须具有相同的shape和格式。用户在使用之前需要设置环境变量,运行下面的例子。获取详情请点击官方网站 `MindSpore `_ 。 **参数:** diff --git a/docs/api/api_python/ops/mindspore.ops.AllReduce.rst b/docs/api/api_python/ops/mindspore.ops.AllReduce.rst index ca0c88234e6..4cd82158083 100644 --- a/docs/api/api_python/ops/mindspore.ops.AllReduce.rst +++ b/docs/api/api_python/ops/mindspore.ops.AllReduce.rst @@ -10,7 +10,7 @@ **参数:** - - **op** (str) - 规约的具体操作,如sum、max、和min。默认值:ReduceOp.SUM。 + - **op** (str) - 规约的具体操作,如"sum"、"max"、和"min"。默认值:ReduceOp.SUM。 - **group** (str) - 工作的通信组。默认值:"GlobalComm.WORLD_COMM_GROUP"(即Ascend平台为"hccl_world_group",GPU平台为"nccl_world_group" )。 **输入:** diff --git a/docs/api/api_python/ops/mindspore.ops.ArgMaxWithValue.rst b/docs/api/api_python/ops/mindspore.ops.ArgMaxWithValue.rst index a164d4dfc3e..0833db88dc7 100644 --- a/docs/api/api_python/ops/mindspore.ops.ArgMaxWithValue.rst +++ b/docs/api/api_python/ops/mindspore.ops.ArgMaxWithValue.rst @@ -27,7 +27,7 @@ tuple (Tensor),表示2个Tensor组成的tuple,包含对应的索引和输入Tensor的最大值。 - - **index** (Tensor) - 输入Tensor最大值的索引。如果 `keep_dims` 为true,则输出Tensor的shape为 :math:`(x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)` 。否则,shape为 :math:`(x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)` 。 + - **index** (Tensor) - 输入Tensor最大值的索引。如果 `keep_dims` 为True,则输出Tensor的shape为 :math:`(x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)` 。否则,shape为 :math:`(x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)` 。 - **output_x** (Tensor) - 输入Tensor的最大值,其shape与索引相同。 **异常:** diff --git a/docs/api/api_python/ops/mindspore.ops.Argmax.rst b/docs/api/api_python/ops/mindspore.ops.Argmax.rst index f271f82b89e..000a4c8bdc8 100644 --- a/docs/api/api_python/ops/mindspore.ops.Argmax.rst +++ b/docs/api/api_python/ops/mindspore.ops.Argmax.rst @@ -16,9 +16,9 @@ - **input_x** (Tensor):Argmax的输入,任意维度的Tensor。支持的数据类型如下所示: - - Ascend:Float16和Float32。 - - GPU:Float16和Float32。 - - CPU:Float16、Float32和Float64。 + - Ascend:float16和float32。 + - GPU:float16和float32。 + - CPU:float16、float32和float64。 **输出:** diff --git a/docs/api/api_python/ops/mindspore.ops.AvgPool3D.rst b/docs/api/api_python/ops/mindspore.ops.AvgPool3D.rst index 7264df6f0b5..8c6e85d813b 100644 --- a/docs/api/api_python/ops/mindspore.ops.AvgPool3D.rst +++ b/docs/api/api_python/ops/mindspore.ops.AvgPool3D.rst @@ -17,9 +17,9 @@ **参数:** - - **kernel_size** (Union[int, tuple[int]]) - 指定池化核尺寸大小,是一个整数,表示深度、高度和宽度,或者是含3个分别表示深度、高度和宽度整数的tuple。默认值:1。 - - **strides** (Union[int, tuple[int]]) - 池化操作的移动步长,是一个整数,表示移动深度、高度和宽度,或者是含3个分别表示移动深度、高度和宽度整数的tuple。默认值:1。 - - **pad_mode** (str) - 指定池化填充模式,可选值有:"SAME"、"VALID"或"PAD"。默认值:"VALID"。 + - **kernel_size** (Union[int, tuple[int]]) - 指定池化核尺寸大小,是一个整数,对应深度、高度和宽度,或者是含3个分别对应深度、高度和宽度整数的tuple。默认值:1。 + - **strides** (Union[int, tuple[int]]) - 池化操作的移动步长,是一个整数,对应移动深度、高度和宽度,或者是含3个分别表对应移动深度、高度和宽度整数的tuple。默认值:1。 + - **pad_mode** (str) - 指定池化填充模式,可选值有:"same"、"valid"或"pad"。默认值:"valid"。 - **same** - 输出的深度、高度和宽度分别与输入整除 `stride` 后的值相同。 - **valid** - 在不填充的前提下返回有效计算所得的输出。不满足计算的多余像素会被丢弃。 diff --git a/docs/api/api_python/ops/mindspore.ops.MaxPool3D.rst b/docs/api/api_python/ops/mindspore.ops.MaxPool3D.rst index a87ea08361e..10fc560a91f 100644 --- a/docs/api/api_python/ops/mindspore.ops.MaxPool3D.rst +++ b/docs/api/api_python/ops/mindspore.ops.MaxPool3D.rst @@ -16,14 +16,14 @@ mindspore.ops.MaxPool3D - **kernel_size** (Union[int, tuple[int]]) - 指定池化核尺寸大小。整数类型,表示池化核深度、高和宽,或者是三个整数组成的元组,表示深、高和宽。默认值:1。 - **strides** (Union[int, tuple[int]]) - 池化操作的移动步长,整数类型,表示深、高和宽的移动步长,或者是三个整数组成的元组,表示深、高和宽移动步长。默认值:1。 - - **pad_mode** (str) - 指定池化填充模式,可选值有:"same"或"valid"。默认值:"valid"。 + - **pad_mode** (str) - 指定池化填充模式,可选值有:"same"、"valid"或"pad"。默认值:"valid"。 - same:输出的宽度于输入整数 `stride` 后的值相同。 - valid:在不填充的前提下返回有效计算所得的输出。不满足计算的多余像素会被丢弃。 - - pad:对输入进行填充。 在输入的深度、高度和宽度方向上填充 `pad` 大小的0。如果设置此模式, `pad` 必须大于或等于0。 + - pad:对输入进行填充。 在输入的深度、高度和宽度方向上填充 `pad` 大小的0。如果设置此模式, `pad_list` 必须大于或等于0。 - **pad_list** (Union(int, tuple[int])) - 池化填充方式。默认值:0。如果 `pad` 是一个整数,则头尾部、顶部,底部,左边和右边的填充都是相同的,等于 `pad` 。如果 `pad` 是六个整数的tuple,则头尾部、顶部、底部、左边和右边的填充分别等于填充pad[0]、pad[1]、pad[2]、pad[3]、pad[4]和pad[5]。 - - **ceil_mode** (bool) - 是否使用ceil函数计算输出高度和宽度。默认值:None。 + - **ceil_mode** (Union[bool, None]) - 是否使用ceil函数计算输出高度和宽度。默认值:None。 - **data_format** (str) - 输入和输出的数据格式。目前仅支持'NCDHW'。默认值:'NCDHW'。 **输入:** diff --git a/mindspore/python/mindspore/nn/layer/activation.py b/mindspore/python/mindspore/nn/layer/activation.py index 549792a9ea1..14cb3a766f7 100644 --- a/mindspore/python/mindspore/nn/layer/activation.py +++ b/mindspore/python/mindspore/nn/layer/activation.py @@ -307,7 +307,7 @@ class ReLU6(Cell): .. math:: - \min(\max(0, x), 6). + Y = \min(\max(0, x), 6). The input is a Tensor of any valid shape. @@ -621,7 +621,7 @@ class PReLU(Cell): .. math:: - prelu(x_i)= \max(0, x_i) + w * \min(0, x_i), + PReLU(x_i)= \max(0, x_i) + w * \min(0, x_i), where :math:`x_i` is an element of an channel of the input. diff --git a/mindspore/python/mindspore/nn/layer/basic.py b/mindspore/python/mindspore/nn/layer/basic.py index ed8b9fe0ef0..c70ee93e573 100644 --- a/mindspore/python/mindspore/nn/layer/basic.py +++ b/mindspore/python/mindspore/nn/layer/basic.py @@ -706,7 +706,7 @@ class Pad(Cell): Raises: TypeError: If `paddings` is not a tuple. - ValueError: If length of `paddings` is more than 4 or its shape is not (n, 2). + ValueError: If length of `paddings` is more than 4 or its shape is not (N, 2). ValueError: If `mode` is not one of 'CONSTANT', 'REFLECT', 'SYMMETRIC'. Supported Platforms: diff --git a/mindspore/python/mindspore/nn/layer/normalization.py b/mindspore/python/mindspore/nn/layer/normalization.py index 094ab5f2cb7..10a2cd2afa7 100644 --- a/mindspore/python/mindspore/nn/layer/normalization.py +++ b/mindspore/python/mindspore/nn/layer/normalization.py @@ -794,7 +794,7 @@ class LayerNorm(Cell): epsilon (float): A value added to the denominator for numerical stability. Default: 1e-7. Inputs: - - **x** (Tensor) - The shape of 'x' is :math:`(x_1, x_2, ..., x_R)`, + - **x** (Tensor) - The shape of `x` is :math:`(x_1, x_2, ..., x_R)`, and `input_shape[begin_norm_axis:]` is equal to `normalized_shape`. Outputs: diff --git a/mindspore/python/mindspore/nn/layer/rnn_cells.py b/mindspore/python/mindspore/nn/layer/rnn_cells.py index 9e501702e9b..63ca8d71c07 100644 --- a/mindspore/python/mindspore/nn/layer/rnn_cells.py +++ b/mindspore/python/mindspore/nn/layer/rnn_cells.py @@ -332,10 +332,15 @@ class GRUCell(RNNCellBase): `Learning Phrase Representations using RNN Encoder–Decoder for Statistical Machine Translation `_. + The LSTMCell can be simplified in NN layer, the following formula: + + .. math:: + h^{'},c^{'} = LSTMCell(x, (h_0, c_0)) + Args: input_size (int): Number of features of input. hidden_size (int): Number of features of hidden layer. - has_bias (bool): Whether the cell has bias `b_ih` and `b_hh`. Default: True. + has_bias (bool): Whether the cell has bias `b_in` and `b_hn`. Default: True. Inputs: - **x** (Tensor) - Tensor of shape (batch_size, `input_size`). diff --git a/mindspore/python/mindspore/nn/layer/rnns.py b/mindspore/python/mindspore/nn/layer/rnns.py index 5b27d2679e9..94174e9eacb 100644 --- a/mindspore/python/mindspore/nn/layer/rnns.py +++ b/mindspore/python/mindspore/nn/layer/rnns.py @@ -612,7 +612,7 @@ class RNN(_RNNBase): use this input when **x** has padding elements. Outputs: - Tuple, a tuple contains (`output`, `h_n`). + Tuple, a tuple contains (`output`, `hx_n`). - **output** (Tensor) - Tensor of shape (seq_len, batch_size, num_directions * `hidden_size`) or (batch_size, seq_len, num_directions * `hidden_size`). diff --git a/mindspore/python/mindspore/nn/loss/loss.py b/mindspore/python/mindspore/nn/loss/loss.py index c13b9223ba4..593868ce682 100644 --- a/mindspore/python/mindspore/nn/loss/loss.py +++ b/mindspore/python/mindspore/nn/loss/loss.py @@ -330,7 +330,7 @@ class RMSELoss(LossBase): and they should be broadcasted to each other. Outputs: - Tensor, weighted loss float tensor and its shape is zero. + Tensor, weighted loss float tensor and its shape is (). Supported Platforms: ``Ascend`` ``GPU`` ``CPU`` @@ -510,6 +510,8 @@ class SoftMarginLoss(LossBase): .. math:: \text{loss}(x, y) = \sum_i \frac{\log(1 + \exp(-y[i]*x[i]))}{\text{x.nelement}()} + :math:`x.nelement()` represents the number of element of `x` . + Args: reduction (str): Apply specific reduction method to the output: 'none', 'mean', 'sum'. Default: "mean". diff --git a/mindspore/python/mindspore/ops/operations/nn_ops.py b/mindspore/python/mindspore/ops/operations/nn_ops.py index 44416f8714e..79397bd7260 100644 --- a/mindspore/python/mindspore/ops/operations/nn_ops.py +++ b/mindspore/python/mindspore/ops/operations/nn_ops.py @@ -1712,7 +1712,7 @@ class MaxPool3D(PrimitiveWithInfer): strides (Union[int, tuple[int]]): The distance of kernel moving, an int number that represents not only the depth, height of movement but also the width of movement,, or a tuple of three int numbers that represent depth, height and width of movement respectively. Default: 1. - pad_mode (str): The optional value of pad mode is "same" or "valid". + pad_mode (str): The optional value of pad mode is "same", "valid" or "pad". Default: "valid". - same: Adopts the way of completion. The height and width of the output will be the same as @@ -1724,13 +1724,14 @@ class MaxPool3D(PrimitiveWithInfer): will be returned without padding. Extra pixels will be discarded. - pad: Implicit paddings on both sides of the input in depth, height and width. The number of "pad" will - be padded to the input Tensor borders. "pad" must be greater than or equal to 0. + be padded to the input Tensor borders. "pad_list" must be greater than or equal to 0. pad_list (Union(int, tuple[int])): The pad value to be filled. Default: 0. If `pad` is an integer, the paddings of head, tail, top, bottom, left and right are the same, equal to pad. If `pad` is a tuple of six integers, the padding of head, tail, top, bottom, left and right equals to pad[0], pad[1], pad[2], pad[3], pad[4] and pad[5] correspondingly. - ceil_mode (bool): Whether to use ceil instead of floor to calculate output shape. Only effective in "pad" mode. + ceil_mode (Union[bool, None]): Whether to use ceil instead of floor to calculate output shape. + Only effective in "pad" mode. When "pad_mode" is "pad" and "ceil_mode" is "None", "ceil_mode" will be set as "False". Default: None. data_format (str) : The optional value for data format. Currently only support 'NCDHW'. Default: 'NCDHW'. @@ -7530,8 +7531,8 @@ class AvgPool3D(Primitive): strides (Union[int, tuple[int]]): The distance of kernel moving, an int number that represents the depth, height and width of movement are both strides, or a tuple of three int numbers that represent depth, height and width of movement respectively. Default: 1. - pad_mode (str): The optional value for pad mode, is "SAME", "VALID", "PAD". - Default: "VALID". + pad_mode (str): The optional value for pad mode, is "same", "valid", "pad". + Default: "valid". - same: Adopts the way of completion. The depth, height and width of the output will be the same as the input. The total number of padding will be calculated in depth, horizontal and vertical