From 2d1c355b86c26b4f189f04dd412d665453c48de6 Mon Sep 17 00:00:00 2001 From: lilinjie Date: Sat, 25 Feb 2023 16:53:19 +0800 Subject: [PATCH] update ops docs --- .../ops/mindspore.ops.FractionalAvgPool.rst | 17 ++- .../ops/mindspore.ops.FractionalMaxPool.rst | 23 ++-- .../api_python/ops/mindspore.ops.Geqrf.rst | 8 +- .../api_python/ops/mindspore.ops.HSVToRGB.rst | 2 +- .../ops/mindspore.ops.MatrixBandPart.rst | 4 +- .../ops/mindspore.ops.MatrixDiagV3.rst | 4 +- .../ops/mindspore.ops.MatrixSetDiagV3.rst | 32 ++--- .../ops/mindspore.ops.MaxUnpool2D.rst | 2 +- .../ops/mindspore.ops.MultiMarginLoss.rst | 2 +- .../mindspore.ops.MultilabelMarginLoss.rst | 6 +- .../ops/mindspore.ops.NonMaxSuppressionV3.rst | 13 +- ...pore.ops.NonMaxSuppressionWithOverlaps.rst | 7 +- .../mindspore/ops/operations/array_ops.py | 102 ++++++++------- .../mindspore/ops/operations/image_ops.py | 71 ++++++----- .../mindspore/ops/operations/linalg_ops.py | 11 +- .../mindspore/ops/operations/math_ops.py | 15 +-- .../python/mindspore/ops/operations/nn_ops.py | 119 ++++++++++-------- 17 files changed, 237 insertions(+), 201 deletions(-) diff --git a/docs/api/api_python/ops/mindspore.ops.FractionalAvgPool.rst b/docs/api/api_python/ops/mindspore.ops.FractionalAvgPool.rst index 0c3792208b8..b51a2b57714 100644 --- a/docs/api/api_python/ops/mindspore.ops.FractionalAvgPool.rst +++ b/docs/api/api_python/ops/mindspore.ops.FractionalAvgPool.rst @@ -5,9 +5,8 @@ mindspore.ops.FractionalAvgPool 在输入上执行分数平均池化。 - 分数平均池化类似于常规平均池化。在常规平均池中,可以通过获取集合中较小的 `N x N` 子部分(通常为2x2)的平均值来缩小输入集的大小, - - 并尝试将集合减少N的因子,其中N是整数。分数平均池化,意味着整体缩减比N不必是整数。在每个池化区域中,执行均值运算。 + 分数平均池化类似于常规平均池化。在常规平均池化中,通过取集合较小的 `N x N` 子部分的平均值(通常为2x2)来缩小输入集的大小,目标是将集合缩小 `N` 倍,其中 `N` 为整数。 + 但分数平均池化具有额外的灵活性,允许总缩小比率 `N` 为非整数值。 .. warning:: `pooling_ratio` 当前只支持行和列轴,并行大于1.0,第一个和最后一个元素必须为1.0,因为我们不允许对batch和通道轴进行池化。 @@ -15,14 +14,14 @@ mindspore.ops.FractionalAvgPool 参数: - **pooling_ratio** (list(float)) - 决定了输出的shape,数据类型是floats的列表,长度大于等于4。其值为每个维度的池化比率,目前仅支持行和列维度, 应该大于等于0。第一个和最后一个元素必须为1.0,不支持对batch和通道轴进行池化。 - - **pseudo_random** (bool,可选) - 当设置为True时,以伪随机方式生成池序列,为False时,以随机方式生成池序列。默认为False。 - 查看文章 `Fractional Max-Pooling `_ 以了解伪随机和随机之间的差异。 + - **pseudo_random** (bool,可选) - 控制序列生成机制是随机或伪随机。当设置为True时,以伪随机方式生成池序列,为False时,以随机方式生成池序列。默认值:False。 + 参考 Benjamin Graham 的论文 `Fractional Max-Pooling `_ 以了解伪随机和随机池化之间的差异。 - **overlapping** (bool,可选) - 当设置为True时,表示两个单元格都使用相邻池化单元边界的值进行池化, - 设置为False时,表示值不进行重复使用。默认为False。 + 设置为False时,表示值不进行重复使用。默认值:False。 - **deterministic** (bool,可选) - 当设置为True时,将在计算图中的FractionalAvgPool节点上进行迭代时使用固定池区域。 - 主要用于单元测试,使FractionalAvgPool具有确定性。当设置为False时,将不使用固定池区域。默认为False。 - - **seed** (int,可选) - 如果seed或seed2被设置为非零,则随机数生成器由给定的seed生成,否则,它由随机种子生成。默认为0。 - - **seed2** (int,可选) - 第二个seed,以避免发生seed碰撞。默认为0。 + 主要用于单元测试,使FractionalAvgPool具有确定性。当设置为False时,将不使用固定池区域。默认值:False。 + - **seed** (int,可选) - 如果seed或seed2被设置为非零,则随机数生成器由给定的seed生成,否则,它由随机种子生成。默认值:0。 + - **seed2** (int,可选) - 第二个seed,以避免发生seed碰撞。默认值:0。 输入: - **x** (Tensor) - 数据类型必须为:float32、float64、int32、int64。shape为 :math:`(N, H_{in}, W_{in}, C_{in})` 。 diff --git a/docs/api/api_python/ops/mindspore.ops.FractionalMaxPool.rst b/docs/api/api_python/ops/mindspore.ops.FractionalMaxPool.rst index 664d3886733..8783abe7f7b 100644 --- a/docs/api/api_python/ops/mindspore.ops.FractionalMaxPool.rst +++ b/docs/api/api_python/ops/mindspore.ops.FractionalMaxPool.rst @@ -5,24 +5,23 @@ mindspore.ops.FractionalMaxPool 在输入上执行分数最大池化。 - 分数最大池化类似于常规最大池化。在常规最大池中,通过获取集合中较小N×N子部分的最大值(通常为2x2)来缩小输入集的大小,并尝试将集合减少N倍,其中N是整数。 - - 分数最大池化意味着整体缩减比率N不必是整数。池区域的大小是随机生成的,但是相当均匀。 + 分数最大池化类似于常规最大池化。在常规最大池化中,通过取集合较小的 `N x N` 的子部分的最大值(通常为2x2)来缩小输入集的大小,目标是将集合缩小 `N` 倍,其中 `N` 为整数。 + 但分数最大池化具有额外的灵活性,允许总缩小比率 `N` 为非整数值。 + .. warning:: `pooling_ratio` 当前只支持行和列轴,并行大于1.0,第一个和最后一个元素必须为1.0,因为我们不允许对batch和通道轴进行池化。 参数: - - **pooling_ratio** (list(float)) - 决定了输出的shape,floats列表,长度大于等于4。对每个轴的value应该大于等于0,目前仅支持行和列维度。 - 第一个和最后一个元素必须为1.0,因为我们不允许对batch和通道轴进行池化。 - - **pseudo_random** (bool,可选) - 当设置为True时,以伪随机方式生成池序列,否则以随机方式生成池序列。默认为False。 - 查看文章 `Fractional Max-Pooling `_ 以了解伪随机和随机之间的差异。 - - **overlapping** (bool,可选) - 当设置为True时,表示池化时,两个单元格都使用相邻池化单元边界的值, - 设置为False时,表示值不进行重复使用。默认为False。 + - **pooling_ratio** (list(float)) - 决定了输出的shape,floats列表,长度大于等于4。对每个轴的value不能小于零0,目前仅支持行和列维度。 + - **pseudo_random** (bool,可选) - 控制序列生成机制是随机或伪随机。当设置为True时,以伪随机方式生成池序列,为False时,以随机方式生成池序列。默认值:False。 + 参考 Benjamin Graham 的论文 `Fractional Max-Pooling `_ 以了解伪随机和随机池化之间的差异。 + - **overlapping** (bool,可选) - 当设置为True时,表示两个单元格都使用相邻池化单元边界的值进行池化, + 设置为False时,表示值不进行重复使用。默认值:False。 - **deterministic** (bool,可选) - 当设置为True时,将在计算图中的FractionalMaxPool节点上进行迭代时使用固定池区域。 - 主要用于单元测试,使FractionalMaxPool具有确定性。当设置为False时,将不使用固定池区域。默认为False。 - - **seed** (int,可选) - 如果seed或seed2被设置为非零,则随机数生成器由给定的seed生成,否则,它由随机种子生成。默认为0。 - - **seed2** (int,可选) - 第二个seed,以避免发生seed碰撞。默认为0。 + 主要用于单元测试,使FractionalMaxPool具有确定性。当设置为False时,将不使用固定池区域。默认值:False。 + - **seed** (int,可选) - 如果seed或seed2被设置为非零,则随机数生成器由给定的seed生成,否则,它由随机种子生成。默认值:0。 + - **seed2** (int,可选) - 第二个seed,以避免发生seed碰撞。默认值:0。 输入: - **x** (Tensor) - 数据类型必须为:float32、float64、int32、int64。shape为: :math:`(N, H_{in}, W_{in}, C_{in})` 。 diff --git a/docs/api/api_python/ops/mindspore.ops.Geqrf.rst b/docs/api/api_python/ops/mindspore.ops.Geqrf.rst index 5fcb9339e7c..7bbd9e7155b 100644 --- a/docs/api/api_python/ops/mindspore.ops.Geqrf.rst +++ b/docs/api/api_python/ops/mindspore.ops.Geqrf.rst @@ -3,11 +3,11 @@ mindspore.ops.Geqrf .. py:class:: mindspore.ops.Geqrf - 用于计算QR分解的低级函数。此函数返回两个Tensor(y,tau)。 + 将矩阵分解为正交矩阵 `Q` 和上三角矩阵 `R` 的乘积。该过程称为QR分解: :math:`A = QR` 。 - 计算 `x` 的QR分解。 `Q` 和 `R` 矩阵都存储在同一个输出Tensor `y` 中。 - - `R` 的元素存储在对角线及上方。隐式定义矩阵 `Q` 的基本反射器(或户主向量)存储在对角线下方。 + `Q` 和 `R` 矩阵都存储在同一个输出Tensor `y` 中。 `R` 的元素存储在对角线及上方。隐式定义矩阵 `Q` 的基本反射器(或户主向量)存储在对角线下方。 + + 此函数返回两个Tensor( `y`, `tau` )。 输入: - **x** (Tensor) - shape为 :math:`(*, m, n)` ,输入矩阵维度必须为大于等于两维,支持dtype为float32、float64、complex64、complex128。 diff --git a/docs/api/api_python/ops/mindspore.ops.HSVToRGB.rst b/docs/api/api_python/ops/mindspore.ops.HSVToRGB.rst index 2e2a69e6a40..5e79b20c153 100644 --- a/docs/api/api_python/ops/mindspore.ops.HSVToRGB.rst +++ b/docs/api/api_python/ops/mindspore.ops.HSVToRGB.rst @@ -3,7 +3,7 @@ mindspore.ops.HSVToRGB .. py:class:: mindspore.ops.HSVToRGB - 将一个或多个图像从HSV转换为RGB。图像的格式应为:NHWC。 + 将一个或多个图像从HSV颜色空间转换为RGB颜色空间,其中每个像素的HSV值转换为其对应的RGB值。此函数仅适用于输入像素值在[0,1]范围内的情况。图像的格式应为:NHWC。 输入: - **x** (Tensor) - 输入的图像必须是shape为 :math:`[batch, image\_height, image\_width, channel]` 的四维Tensor。 diff --git a/docs/api/api_python/ops/mindspore.ops.MatrixBandPart.rst b/docs/api/api_python/ops/mindspore.ops.MatrixBandPart.rst index db19b2590e3..9becd4e5c11 100644 --- a/docs/api/api_python/ops/mindspore.ops.MatrixBandPart.rst +++ b/docs/api/api_python/ops/mindspore.ops.MatrixBandPart.rst @@ -3,6 +3,6 @@ mindspore.ops.MatrixBandPart .. py:class:: mindspore.ops.MatrixBandPart - 复制一个Tensor,将每个最内层矩阵中中心带之外的所有值都设置为零。 + 提取一个Tensor中每个矩阵的中心带,中心带之外的所有值都设置为零。 - 更多参考详见 :func:`mindspore.ops.matrix_band_part`。 + 更多参考详见 :func:`mindspore.ops.matrix_band_part` 。 diff --git a/docs/api/api_python/ops/mindspore.ops.MatrixDiagV3.rst b/docs/api/api_python/ops/mindspore.ops.MatrixDiagV3.rst index 01328ddf6ee..842b5a9b3ab 100644 --- a/docs/api/api_python/ops/mindspore.ops.MatrixDiagV3.rst +++ b/docs/api/api_python/ops/mindspore.ops.MatrixDiagV3.rst @@ -3,6 +3,6 @@ mindspore.ops.MatrixDiagV3 .. py:class:: mindspore.ops.MatrixDiagV3 - 返回一个batch的对角Tensor,其具有给定的对角线值。 + 将给定的输入Tensor构造为对角矩阵或一批对角矩阵。 - 更多参考详见 :func:`mindspore.ops.matrix_diag`。 + 更多参考详见 :func:`mindspore.ops.matrix_diag` 。 diff --git a/docs/api/api_python/ops/mindspore.ops.MatrixSetDiagV3.rst b/docs/api/api_python/ops/mindspore.ops.MatrixSetDiagV3.rst index 433ed7cd98a..1b10f057510 100644 --- a/docs/api/api_python/ops/mindspore.ops.MatrixSetDiagV3.rst +++ b/docs/api/api_python/ops/mindspore.ops.MatrixSetDiagV3.rst @@ -3,38 +3,40 @@ mindspore.ops.MatrixSetDiagV3 .. py:class:: mindspore.ops.MatrixSetDiagV3(align="RIGHT_LEFT") - 返回具有新的对角线值的批处理矩阵Tensor。 - 给定输入 `x` 和对角线 `diagonal` ,此操作返回与 `x` 具有相同shape和值的Tensor,但返回的Tensor除开最内层矩阵的对角线, - 这些值将被对角线中的值覆盖。如果某些对角线比 `max_diag_len` 短,则需要被填充,其中 `max_diag_len` 指对角线的最长长度。 + 返回一批具有新的对角线值的矩阵的Tensor。 + 给定输入 `x` 和对角线 `diagonal` ,此操作返回与 `x` 具有相同shape和值的Tensor。但返回的Tensor除了最内层矩阵的对角线, + 这些值将被对角线中的值覆盖。 + + 如果某些对角线比 `max_diag_len` 短,则需要被填充,其中 `max_diag_len` 指对角线的最长长度。 `diagonal` 的维度 :math:`shape[-2]` 必须等于对角线个数 `num_diags` , :math:`num\_diags = k[1] - k[0] + 1`, `diagonal` 的维度 :math:`shape[-1]` 必须等于最长对角线值 `max_diag_len` , :math:`max\_diag\_len = min(x.shape[-2] + min(k[1], 0), x.shape[-1] + min(-k[0], 0))` 。 - 设 `x` 具有 `r + 1` 维 :math:`[I, J, ..., L, M, N]` 。 - 当 `k` 是整数或 :math:`k[0] == k[1]` 时,对角线 `diagonal` 的shape为 :math:`[I, J, ..., L, max\_diag\_len]` 。 - 否则,其shape为 :math:`[I, J, ... L, num\_diags, max\_diag\_len]` 。 + + 设 `x` 是一个n维Tensor,shape为: :math:`(d_1, d_2, ..., d_{n-2}, d_{n-1}, d_n)` 。 + 当 `k` 是一个整数或 :math:`k[0] == k[1]` 时, `diagonal` 为n-1维Tensor,shape为 :math:`(d_1, d_2, ..., d_{n-2}, max\_diag\_len)` 。 + 否则, `diagonal` 与 `x` 维度一致,其shape为 :math:`(d_1, d_2, ..., d_{n-2}, num\_diags, max\_diag\_len)` 。 参数: - - **align** (str,可选) - 字符串,指定超对角线和次对角线的对齐方式。 + - **align** (str,可选) - 可选字符串,指定超对角线和次对角线的对齐方式。 可选值:"RIGHT_LEFT"、"LEFT_RIGHT"、"LEFT_LEFT"、"RIGHT_RIGHT"。 默认值:"RIGHT_LEFT"。 - "RIGHT_LEFT"表示将超对角线与右侧对齐(左侧填充行),将次对角线与左侧对齐(右侧填充行)。 - "LEFT_RIGHT"表示将超对角线与左侧对齐(右侧填充行),将次对角线与右侧对齐(左侧填充行)。 - - "LEFT_LEFT"表示将超对角线与左侧对齐(右侧填充行),将次对角线与左侧对齐(右侧填充行)。 - - "RIGHT_RIGHT"表示将超对角线与右侧对齐(左侧填充行),将次对角线与右侧对齐(左侧填充行)。 - + - "LEFT_LEFT"表示将超对角线和次对角线均与左侧对齐(右侧填充行)。 + - "RIGHT_RIGHT"表示将超对角线与次对角线均右侧对齐(左侧填充行)。 + 输入: - - **x** (Tensor) - Tensor,其维度为 `r+1` 需要满足 `r >=1` 。 + - **x** (Tensor) - n维Tensor,其中 :math:`n >= 2` 。 - **diagonal** (Tensor) - 输入对角线Tensor,具有与 `x` 相同的数据类型。 - 当 `k` 是整数或 :math:`k[0] == k[1]` 时,其为维度 `r` ,否则,其维度为 `r + 1` 。 + 当 `k` 是整数或 :math:`k[0] == k[1]` 时,其为维度 `n-1` ,否则,其维度为 `n` 。 - **k** (Tensor) - int32类型的Tensor。对角线偏移量。正值表示超对角线,0表示主对角线,负值表示次对角线。 `k` 可以是单个整数(对于单个对角线)或一对整数,分别指定矩阵带的上界和下界,且 `k[0]` 不得大于 `k[1]` 。 其值必须在 :math:`(-x.shape[-2], x.shape[-1])` 中。采用图模式时,输入 `k` 必须是常量Tensor。 输出: - Tensor,与 `x` 的类型相同。 - 设 `x` 有 `r+1` 维 :math:`[I, J, ..., M, N]` 。 - 则,输出Tensor的维度为 `r+1` 维 :math:`[I, J, ..., L, M, N]` ,与输入 `x` 相同。 + Tensor,数据类型和shape与 `x` 相同。 + 异常: - **TypeError** - 若任一输入不是Tensor。 diff --git a/docs/api/api_python/ops/mindspore.ops.MaxUnpool2D.rst b/docs/api/api_python/ops/mindspore.ops.MaxUnpool2D.rst index 3e40cee3692..13c372be288 100644 --- a/docs/api/api_python/ops/mindspore.ops.MaxUnpool2D.rst +++ b/docs/api/api_python/ops/mindspore.ops.MaxUnpool2D.rst @@ -5,7 +5,7 @@ mindspore.ops.MaxUnpool2D MaxPool2D的逆过程。 - MaxUnpool2D在计算过程中,保留最大值位置的元素,并将非最大值位置元素设置为0。 + 由于MaxPool2D会丢失非最大值,因此它不是完全可逆的。MaxUnpool2D将MaxPool2D的输出作为输入,包括最大值的索引,并计算部分逆,其中所有非最大值都被设置为零。 例如,输入的shape为 :math:`(N, C, H_{in}, W_{in})` ,输出的shape为 :math:`(N, C, H_{out}, W_{out})` , 则该操作如下式所示: diff --git a/docs/api/api_python/ops/mindspore.ops.MultiMarginLoss.rst b/docs/api/api_python/ops/mindspore.ops.MultiMarginLoss.rst index 3cc666eaf53..412efb8f5e8 100644 --- a/docs/api/api_python/ops/mindspore.ops.MultiMarginLoss.rst +++ b/docs/api/api_python/ops/mindspore.ops.MultiMarginLoss.rst @@ -3,6 +3,6 @@ mindspore.ops.MultiMarginLoss .. py:class:: mindspore.ops.MultiMarginLoss(p=1, margin=1.0, reduction="mean") - 创建一个标准,用于优化输入和输出之间的多类分类铰链损失(基于边距的损失)。 + 创建一个损失函数,用于优化输入和输出之间的多类分类 hinge 损失(基于边界的损失)。 更多细节请参考 :func:`mindspore.ops.multi_margin_loss` 。 diff --git a/docs/api/api_python/ops/mindspore.ops.MultilabelMarginLoss.rst b/docs/api/api_python/ops/mindspore.ops.MultilabelMarginLoss.rst index 97c0af60fac..792f2571bab 100644 --- a/docs/api/api_python/ops/mindspore.ops.MultilabelMarginLoss.rst +++ b/docs/api/api_python/ops/mindspore.ops.MultilabelMarginLoss.rst @@ -3,9 +3,7 @@ mindspore.ops.MultilabelMarginLoss .. py:class:: mindspore.ops.MultilabelMarginLoss(reduction='mean') - 二维卷积层。 - - 创建一个标准,用于优化输入 :math:`x` (一个2D小批量Tensor) - 和输出 :math:`y` (一个目标类别索引的2DTensor)之间的多类分类铰链损失(基于边距的损失)。 + 创建一个损失函数,用于最小化多分类任务的基于边际的损失。 + 它以一个2D mini-batch Tensor :math:`x` 作为输入,以包含目标类索引的2D Tensor :math:`y` 作为输出。 更多细节请参考 :func:`mindspore.ops.multilabel_margin_loss` 。 diff --git a/docs/api/api_python/ops/mindspore.ops.NonMaxSuppressionV3.rst b/docs/api/api_python/ops/mindspore.ops.NonMaxSuppressionV3.rst index 21f4e3dcce0..4a3d243d5fc 100644 --- a/docs/api/api_python/ops/mindspore.ops.NonMaxSuppressionV3.rst +++ b/docs/api/api_python/ops/mindspore.ops.NonMaxSuppressionV3.rst @@ -3,10 +3,11 @@ mindspore.ops.NonMaxSuppressionV3 .. py:class:: mindspore.ops.NonMaxSuppressionV3 - 贪婪选取一组按score降序排列后的边界框。 + 按得分降序排列后采用贪婪策略地选择一组边界框,并剪枝掉与先前选择的框具有高重叠交并比(IOU)的框。 + 得分低于 `score_threshold` 的边界框将被删除。 .. warning:: - 如果 `max_output_size` 小于0,将使用0代替。 + 如果 `max_output_size` 小于0,其值将置为0。 .. note:: - 此算法与原点在坐标系中的位置无关。 @@ -14,13 +15,13 @@ mindspore.ops.NonMaxSuppressionV3 输入: - **boxes** (Tensor) - 二维Tensor,shape为 :math:`(num\_boxes, 4)` 。 - - **scores** (Tensor) - 一维Tensor,其shape为 :math:`(num\_boxes)` 。表示对应每一行每个方框的score值, `scores` 和 `boxes` 的num_boxes必须相等。支持的数据类型为float32。 + - **scores** (Tensor) - 一个shape为 :math:`(num\_boxes)` 的一维Tensor,表示每个边框(也就是 `boxes` Tensor的每一行)对应的单个分数。 `scores` 中的分数数量必须与 `boxes` 中的边框的数量相等。支持的数据类型为float32。 - **max_output_size** (Union[Tensor, Number.Int]) - 选取最大的边框数,必须大于等于0,数据类型为int32。 - - **iou_threshold** (Union[Tensor, Number.Float]) - 边框重叠值阈值,重叠值大于此值说明重叠过大,其值必须大于等于0,小于等于1。支持的数据类型为float32。 - - **score_threshold** (Union[Tensor, Number.Float]) - 移除边框阈值,边框score值大于此值则移除相应边框。支持的数据类型为float32。 + - **iou_threshold** (Union[Tensor, Number.Float]) - 边框重叠值阈值,重叠值大于此值说明重叠过大。数据类型为float32,值必须在[0, 1]范围内。 + - **score_threshold** (Union[Tensor, Number.Float]) - 移除边框阈值,score值低于此值则边框被移除。支持的数据类型为float32。 输出: - 一维Tensor,表示被选中边框的index,其shape为 :math:`(M)` ,其中M <= `max_output_size`。 + 一维Tensor,表示被选中边框的index,其shape为 :math:`(M)` ,其中M <= `max_output_size` 。 异常: - **TypeError** - `boxes` 和 `scores` 的数据类型不一致。 diff --git a/docs/api/api_python/ops/mindspore.ops.NonMaxSuppressionWithOverlaps.rst b/docs/api/api_python/ops/mindspore.ops.NonMaxSuppressionWithOverlaps.rst index 4bd370e92ad..95c6705b0ed 100644 --- a/docs/api/api_python/ops/mindspore.ops.NonMaxSuppressionWithOverlaps.rst +++ b/docs/api/api_python/ops/mindspore.ops.NonMaxSuppressionWithOverlaps.rst @@ -3,15 +3,16 @@ mindspore.ops.NonMaxSuppressionWithOverlaps .. py:class:: mindspore.ops.NonMaxSuppressionWithOverlaps - 贪婪选取一组按score降序排列后的边界框。 + 按照得分从高到低贪心地选择一组边界框,同时移除与之前选定的边界框高度重叠的边界框 + 得分低于 `score_threshold` 的边界框将被删除。可以定义自定义重叠标准(例如,IoU,IoA等),重叠值以N-by-N矩阵形式提供。 .. note:: - 此算法与原点在坐标系中的位置无关。 - - 对于坐标系的正交变换和平移,该算法不受影响;因此坐标系的平移变换后算法会选择相同的框。 + - 对于坐标系的正交变换和平移,该算法不受影响,因此坐标系的平移变换后算法会选择相同的框。 输入: - **overlaps** (Tensor) - 二维Tensor,其shape为 :math:`(num\_boxes, num\_boxes)` ,表示n乘n的边框重叠值。支持的数据类型为float16、float32和float64。 - - **scores** (Tensor) - 一维Tensor,其shape为 :math:`(num\_boxes)` 。表示对应每一行每个方框的score值, `scores` 和 `overlaps` 的num_boxes必须相等。数据类型与 `overlaps` 一致。 + - **scores** (Tensor) - 一个shape为 :math:`(num\_boxes)` 的一维Tensor,表示每个边框(也就是 `boxes` Tensor的每一行)对应的单个分数。 `scores` 中的分数数量必须与 `boxes` 中的边框的数量相等。支持的数据类型为float32。 - **max_output_size** (Union[Tensor, Number.Int]) - 选取最大的边框数,必须大于等于0,数据类型为int32。 - **overlap_threshold** (Union[Tensor, Number.Float]) - 边框重叠值阈值,重叠值大于此值说明重叠过大。支持的数据类型为float16、float32和float64。 - **score_threshold** (Union[Tensor, Number.Float]) - 移除边框阈值,边框score值大于此值则移除相应边框。数据类型与 `overlap_threshold` 一致。 diff --git a/mindspore/python/mindspore/ops/operations/array_ops.py b/mindspore/python/mindspore/ops/operations/array_ops.py index 1c74b7deb63..71f3c5bc638 100755 --- a/mindspore/python/mindspore/ops/operations/array_ops.py +++ b/mindspore/python/mindspore/ops/operations/array_ops.py @@ -1250,7 +1250,7 @@ class Size(PrimitiveWithInfer): class MatrixDiagV3(Primitive): """ - Returns a batched diagonal tensor with given batched diagonal values. + Constructs a diagonal matrix or a batch of diagonal matrices from a given input Tensor. Refer to :func:`mindspore.ops.matrix_diag` for more details. @@ -1319,47 +1319,58 @@ class MatrixDiagPartV3(Primitive): class MatrixSetDiagV3(Primitive): r""" - Returns a batched matrix tensor with new batched diagonal values. - Given x and diagonal, this operation returns a tensor with the same shape and values as x, except for the specified - diagonals of the innermost matrices. These will be overwritten by the values in diagonal. Some diagonals are shorter - than `max_diag_len` and need to be padded, where `max_diag_len` is the longest diagonal value. - The diagonal.shape[-2] must be equal to num_diags calculated by :math:`k[1] - k[0] + 1` . + Returns a matrix Tensor with updated diagonal values across batches. + It takes an Tensor `x` and `diagonal` as input and returns a Tensor of + the same shape and values as `x`. But the specified diagonal values in + the innermost matrices will be replaced by the values in the `diagonal`. + + Diagonals shorter than `max_diag_len` need to be padded, where `max_diag_len` is the + longest diagonal value. + The diagonal.shape[-2] must be equal to num_diags calculated by :math:`k[1] - k[0] + 1`. The diagonal.shape[-1] must be equal to the longest diagonal value `max_diag_len` calculated by :math:`min(x.shape[-2] + min(k[1], 0), x.shape[-1] + min(-k[0], 0))` . - Let x have r + 1 dimensions [I, J, ..., L, M, N]. - The diagonal tensor has rank r with shape :math:`[I, J, ..., L, max\_diag\_len]` - when k is an integer or :math:`k[0] == k[1]` . Otherwise, it has rank r + 1 - with shape :math:`[I, J, ..., L, num\_diags, max\_diag\_len]` . + + Assume `x` is an n-D Tensor with shape :math:`(d_1, d_2, ..., d_{n-2}, d_{n-1}, d_n)`. + If `k` is an integer or :math:`k[0] == k[1]`, `diagonal` is an (n-1)-D Tensor with + shape :math:`(d_1, d_2, ..., d_{n-2}, max\_diag\_len)` + Otherwise, it has the same rank as `x` + with shape :math:`(d_1, d_2, ..., d_{n-2}, num\_diags, max\_diag\_len)`. Args: - align (str, optional): An optional string from: "RIGHT_LEFT", "LEFT_RIGHT", "LEFT_LEFT", "RIGHT_RIGHT". - Align is a string specifying how superdiagonals and subdiagonals should be aligned, respectively. + align (str, optional): specifies how superdiagonals and subdiagonals should be aligned. + Supported values:"RIGHT_LEFT", "LEFT_RIGHT", "LEFT_LEFT", "RIGHT_RIGHT". Default: "RIGHT_LEFT". - - "RIGHT_LEFT" aligns superdiagonals to the right (left-pads the row) and subdiagonals to the left - (right-pads the row). - - "LEFT_RIGHT" aligns superdiagonals to the left (right-pads the row) and subdiagonals to the right - (left-pads the row). - - "LEFT_LEFT" aligns superdiagonals to the left (right-pads the row) and subdiagonals to the left - (right-pads the row). - - "RIGHT_RIGHT" aligns superdiagonals to the right (left-pads the row) and subdiagonals to the right - (left-pads the row). + - When set to "RIGHT_LEFT", the alignment of superdiagonals will be towards the right side + (padding the row on the left), while subdiagonals will be towards the left side + (padding the row on the right) + - When set to "LEFT_RIGHT", the alignment of superdiagonals will be towards the left side + (padding the row on the right), while subdiagonals will be towards the right side + (padding the row on the left) + - When set to "LEFT_LEFT", the alignment of both superdiagonals and subdiagonals will be towards + the left side(padding the row on the right). + - When set to "RIGHT_RIGHT", the alignment of both superdiagonals and subdiagonals will be towards + the right side(padding the row on the left). Inputs: - - **x** (Tensor) - Rank r + 1, where r >= 1. - - **diagonal** (Tensor) - A Tensor. Have the same dtype as x. Rank r when k is an integer or k[0] == k[1]. - Otherwise, it has rank r + 1. - - **k** (Tensor) - A Tensor of type int32. Diagonal offset(s). Positive value means superdiagonal, 0 refers to - the main diagonal, and negative value means subdiagonals. k can be a single integer (for a single diagonal) or - a pair of integers specifying the low and high ends of a matrix band. `k[0]` must not be larger than `k[1]` . - The value of `k` has restructions, meaning value of k must be in (-x.shape[-2], x.shape[-1]). - Input k must be const Tensor when taking Graph mode. + - **x** (Tensor) - A n-D Tensor, where :math:`n >= 2`. + - **diagonal** (Tensor) - A Tensor with the same dtype as `x`. Its rank depends on `k`. + If `k` is an integer or :math:`k[0] == k[1]`, its dimension is :math:`n-1`. + Otherwise, it has dimension :math:`n`. + - **k** (Tensor) - Tensor type int32, used for diagonal offset(s). + `k` can either be a single integer, which represents a single diagonal, + or a pair of integers that specify the low and high ends of a matrix band. + In this case(这里是指什么情况下?), `k[0]` should not be greater than `k[1]`. + The value of `k` has restructions, which means that value of `k` must be in range (-x.shape[-2], x.shape[-1]). + Input `k` must be const Tensor when taking Graph mode. + + - `k > 0` refers to a superdiagonal. + - `k = 0` refers to the main diagonal. + - `k < 0` refers to subdiagonals. Outputs: - Tensor. The same type as x. - Let x has r+1 dimensions :math:`[I, J, ..., L, M, N]` . - The output is a tensor of rank r+1 with dimensions :math:`[I, J, ..., L, M, N]` , the same as input x. + Tensor. The same type and shape as `x`. Raises: TypeError: If any input is not Tensor. @@ -1410,7 +1421,8 @@ class MatrixSetDiagV3(Primitive): class MatrixBandPart(Primitive): r""" - Copy a tensor setting everything outside a central band in each innermost matrix to zero. + Extracts the central diagonal band of each matrix in a tensor, with all values outside + the central band set to zero. Refer to :func:`mindspore.ops.matrix_band_part` for more details. @@ -3618,7 +3630,7 @@ class DiagPart(PrimitiveWithCheck): class Mvlgamma(Primitive): r""" - Computes the multivariate log-gamma function with dimension `p` element-wise. + Calculates the multivariate log-gamma function element-wise for a given dimension `p`. Refer to :func:`mindspore.ops.mvlgamma` for more details. @@ -6560,13 +6572,14 @@ class TensorScatterDiv(_TensorScatterOp): class ListDiff(Primitive): - r"""Computes the difference between two lists of numbers. + r""" + This function calculates the disparity between two numerical lists. - Given a list `x` and a list `y`, this operation returns a list `out` that - represents all values that are in `x` but not in `y`. The returned list `out` - is sorted in the same order that the numbers appear in `x` (duplicates are - preserved). This operation also returns a list `idx` that represents the - position of each `out` element in `x`. In other words: + It generates a list of all elements that are present in list `x` but not in list `y`. + The output list `out` retains the same order as the original `x` including duplicate elements. + + Additionally, this class outputs a list `idx` that identifies the position of each element + in `out` within the original `x`. That is to say: :code:`out[i] = x[idx[i]] for i in [0, 1, ..., len(out) - 1]` . Args: @@ -7146,9 +7159,10 @@ class RightShift(Primitive): class LogSpace(Primitive): r""" - Returns a one-dimensional tensor of size steps whose values are evenly - spaced from :math:`base^{start}` to :math:`base^{end}` , inclusive, - on a logarithmic scale with base. + Generates a 1-D Tensor with a length of steps. The tensor's + values are uniformly distributed on a logarithmic scale, ranging from + :math:`base^{start}` to :math:`base^{end}`, including both endpoints. + The logarithmic scale is based on the specified `base`. .. math:: \begin{aligned} @@ -7304,8 +7318,8 @@ class Tril(Primitive): class IndexFill(Primitive): """ - Fills the elements under the dim dimension of the input Tensor with the input value - by selecting the indices in the order given in index. + Fills the specified elements of the input Tensor with a given value, + using the indices specified in the input index array. Refer to :func:`mindspore.ops.index_fill` for more details. diff --git a/mindspore/python/mindspore/ops/operations/image_ops.py b/mindspore/python/mindspore/ops/operations/image_ops.py index d12476fcbc1..fa02ff8a200 100644 --- a/mindspore/python/mindspore/ops/operations/image_ops.py +++ b/mindspore/python/mindspore/ops/operations/image_ops.py @@ -352,33 +352,36 @@ class CropAndResize(Primitive): class NonMaxSuppressionV3(Primitive): r""" - Greedily selects a subset of bounding boxes in descending order of score. + Selects a subset of bounding boxes in a greedy manner, based on their descending score. + It removes boxes that have high intersection-over-union (IOU) overlap with previously + selected boxes, and eliminates boxes with scores lower than a given threshold. .. warning:: When input `max_output_size` is negative, it will be treated as 0. Note: - - This algorithm is agnostic to where the origin is in the coordinate system. - - This algorithm is invariant to orthogonal transformations and translations of the coordinate system, - thus translating or reflections of the coordinate system result in the same boxes being - selected by the algorithm. + - This algorithm does not depend on the location of the origin in the coordinate system. + - This algorithm remains unaffected by orthogonal transformations and translations of + the coordinate system, which means that translating or reflecting the coordinate system + will result in the same boxes being chosen by the algorithm. Inputs: - **boxes** (Tensor) - A 2-D Tensor of shape :math:`(num\_boxes, 4)`. - - **scores** (Tensor) - A 1-D Tensor of shape :math:`(num\_boxes)` representing a single score - corresponding to each box (each row of boxes), the num_boxes of `scores` must be equal to - the num_boxes of `boxes`. + - **scores** (Tensor) - A 1-D Tensor of shape :math:`(num\_boxes)` where each element represents a + single score associated with each box (i.e., each row of the `boxes` Tensor). + It is required that the number of scores in `scores` must be equal to the number of boxes in `boxes`. + The supported data type is float32. - **max_output_size** (Union[Tensor, Number.Int]) - A scalar integer Tensor representing the maximum - number of boxes to be selected by non max suppression. - - **iou_threshold** (Union[Tensor, Number.Float]) - A 0-D float tensor representing the threshold for - deciding whether boxes overlap too much with respect to IOU, and `iou_threshold` must be equal or greater - than 0 and be equal or smaller than 1. - - **score_threshold** (Union[Tensor, Number.Float]) - A 0-D float tensor representing the threshold for - deciding when to remove boxes based on score. + number of boxes to be selected by non max suppression. The supported data type is int32. + - **iou_threshold** (Union[Tensor, Number.Float]) - A scalar float Tensor represents the threshold + used for determining if the intersection over union (IOU) between boxes is too high. + Data type of `iou_threshold` is float32 and must be in range [0, 1]. + - **score_threshold** (Union[Tensor, Number.Float]) - A scalar float Tensor represents the threshold for + determining when to remove boxes based on score. The supported data type is float32. Outputs: A 1-D integer Tensor of shape [M] representing the selected indices from the boxes tensor, - where M <= max_output_size. + where M <= `max_output_size`. Raises: TypeError: If the dtype of `boxes` and `scores` are different. @@ -418,33 +421,40 @@ class NonMaxSuppressionV3(Primitive): class NonMaxSuppressionWithOverlaps(Primitive): r""" - Greedily selects a subset of bounding boxes in descending order of score. + Selects a subset of bounding boxes in a greedy manner by prioritizing those with higher + scores and removing those with high overlaps with previously selected boxes. + Boxes with scores lower than the score threshold are also removed. + The overlap values between boxes are represented as an N-by-N square matrix, + which can be customized to define different overlap criteria such as intersection + over union or intersection over area. + Note: - - This algorithm is agnostic to where the origin is in the coordinate system. - - This algorithm is invariant to orthogonal transformations and translations of the coordinate system; - thus translating or reflections of the coordinate system result in the same boxes being - selected by the algorithm. + - This algorithm does not depend on the location of the origin in the coordinate system. + - This algorithm remains unaffected by orthogonal transformations and translations of + the coordinate system, which means that translating or reflecting the coordinate system + will result in the same boxes being chosen by the algorithm. Inputs: - **overlaps** (Tensor) - A 2-D Tensor of shape :math:`(num\_boxes, num\_boxes)`, representing the n-by-n box overlap values. Types allowed:float16, float32 and float64. - - **scores** (Tensor) - A 1-D Tensor of shape :math:`(num\_boxes)` representing a single score - corresponding to each box (each row of boxes), the num_boxes of `scores` must be equal to - the num_boxes of `overlaps`. It has the same dtype as `overlaps`. + - **scores** (Tensor) - A 1-D Tensor of shape :math:`(num\_boxes)` where each element represents a + single score associated with each box (i.e., each row of the `boxes` Tensor). + It is required that the number of scores in `scores` must be equal to the number of boxes in `boxes`. + The supported data type is float32. - **max_output_size** (Union[Tensor, Number.Int]) - A scalar integer Tensor representing the maximum number of boxes to be selected by non max suppression, and max_output_size must be equal to or greater than 0. Types allowed:int32. - - **overlap_threshold** (Union[Tensor, Number.Float]) - A 0-D float Tensor representing the threshold for - deciding whether boxes overlap too much. + - **overlap_threshold** (Union[Tensor, Number.Float]) - A scalar value, represented by a 0-D float Tensor, + which is used as a threshold to determine if two boxes overlap too much. Types allowed:float16, float32 and float64. - **score_threshold** (Union[Tensor, Number.Float]) - A 0-D float Tensor representing the threshold for deciding when to remove boxes based on score. It has the same dtype as `overlap_threshold`. Outputs: - A 1-D integer Tensor of shape :math:`(M)` representing the selected indices from the boxes Tensor, - where M <= max_output_size. Its data type is int32. + A 1-D integer Tensor of shape :math:`(M)` representing the selected indices from the `boxes` Tensor, + where M <= `max_output_size`. Its data type is int32. Raises: TypeError: If the dtype of `overlaps` , `scores` `overlap_threshold` and `score_threshold` @@ -488,10 +498,9 @@ class NonMaxSuppressionWithOverlaps(Primitive): class HSVToRGB(Primitive): r""" - Convert one or more images from HSV to RGB. - Outputs a tensor of the same shape as the images tensor, - containing the HSV value of the pixels. The output is only - well defined if the value in images are in [0,1]. + Transform one single or a batch of images from HSV to RGB color space. + Each pixel's HSV value is converted to its corresponding RGB value. + Note that the function is only well-defined for input pixel values in the range [0, 1]. Inputs: - **x** (Tensor) - The input image must be a 4-D tensor of shape diff --git a/mindspore/python/mindspore/ops/operations/linalg_ops.py b/mindspore/python/mindspore/ops/operations/linalg_ops.py index f2fcb27d044..ab8202b126b 100644 --- a/mindspore/python/mindspore/ops/operations/linalg_ops.py +++ b/mindspore/python/mindspore/ops/operations/linalg_ops.py @@ -23,13 +23,14 @@ from mindspore.ops.primitive import prim_attr_register class Geqrf(Primitive): r""" - Geqrf is a low-level function for computing QR decompositions. This function returns two tensors - (y, tau). + Decomposes a matrix into the product of an orthogonal matrix `Q` and an upper triangular matrix `R`. + The process is called QR decomposition: :math:`A = QR`. + Both `Q` and `R` matrices are stored in the same output tensor `y`. + The elements of `R` are stored on and above the diagonal, whereas elementary reflectors + (or Householder vectors) implicitly defining matrix `Q` are stored below the diagonal. - Computes a QR decomposition of `x`. Both `Q` and `R` matrices are stored in the same output tensor `y`. - The elements of `R` are stored on and above the diagonal. - Elementary reflectors (or Householder vectors) implicitly defining matrix `Q` are stored below the diagonal. + This function returns two tensors (`y`, `tau`). Inputs: diff --git a/mindspore/python/mindspore/ops/operations/math_ops.py b/mindspore/python/mindspore/ops/operations/math_ops.py index 69a95a7beb6..d1dc033720f 100644 --- a/mindspore/python/mindspore/ops/operations/math_ops.py +++ b/mindspore/python/mindspore/ops/operations/math_ops.py @@ -2818,7 +2818,7 @@ class Hypot(Primitive): class Heaviside(Primitive): r""" - Computes the Heaviside step function for each element in input. + Applies the Heaviside step function for input `x` element-wise. .. math:: \text { heaviside }(\text { x, values })=\left\{\begin{array}{ll} @@ -5486,9 +5486,9 @@ class MatrixInverse(Primitive): class MatrixPower(Primitive): """ - Computes the n-th power of a batch of square matrices. - If n = 0, it returns a batch of identity matrices. If n is negative, it - returns the inverse of each matrix (if invertible) raised to the power of abs(n). + Calculates the n-th power of a batch of square matrices. + When n equals 0, it returns a group of identity matrices. If n is negative, + it computes the inverse of each matrix (if possible) raised to the power of abs(n). Args: n (int) : The exponent, a required int. @@ -5530,7 +5530,7 @@ class MatrixPower(Primitive): class MatrixDeterminant(Primitive): """ - Computes the determinant of one or more square matrices. + Calculates the value of the determinant for one or more square matrices. Refer to :func:`mindspore.ops.det` for more details. @@ -5554,7 +5554,7 @@ class MatrixDeterminant(Primitive): class LogMatrixDeterminant(Primitive): """ - Computes the sign and the log of the absolute value of the determinant of one or more square matrices. + Calculates the sign and logarithm of the determinant of one or more square matrices. Refer to :func:`mindspore.ops.slogdet` for more details. @@ -6109,7 +6109,8 @@ class Igammac(Primitive): class IsClose(Primitive): r""" - Returns a boolean Tensor where two tensors are element-wise equal within a tolerance. + Returns a tensor of Boolean values indicating whether two input tensors + are element-wise equal within a given tolerance. Refer to :func:`mindspore.ops.isclose` for more details. diff --git a/mindspore/python/mindspore/ops/operations/nn_ops.py b/mindspore/python/mindspore/ops/operations/nn_ops.py index d5dbb9dc424..8de1a062743 100644 --- a/mindspore/python/mindspore/ops/operations/nn_ops.py +++ b/mindspore/python/mindspore/ops/operations/nn_ops.py @@ -2001,11 +2001,13 @@ class MaxPool3D(Primitive): class MaxUnpool2D(Primitive): r""" - Computes the inverse of MaxPool2D. + Calculates the partial inverse of MaxPool2D operation. - MaxUnpool2D keeps the maximal value and set all position of non-maximal values to zero. - Typically the input is of shape :math:`(N, C, H_{in}, W_{in})` , the output is of - shape :math:`(N, C, H_{out}, W_{out})` , the operation is as follows: + Since MaxPool2D loses non-maximal values, it is not fully invertible. + Therefore, MaxUnpool2D takes the output of MaxPool2D, including the indices of + the maximal values, and computes a partial inverse where all non-maximal values are set to zero. + Typically the input is of shape :math:`(N, C, H_{in}, W_{in})` , + the output is of shape :math:`(N, C, H_{out}, W_{out})` , the operation is as follows: .. math:: \begin{array}{ll} \\ @@ -2970,8 +2972,9 @@ class SmoothL1Loss(Primitive): class MultiMarginLoss(Primitive): r""" - Creates a criterion that optimizes a multi-class classification hinge loss (margin-based loss) - between input and output. + Creates a loss function that minimizes the margin-based loss or hinge loss + for multi-class classification tasks. + The loss is calculated by comparing the input and output of the function. Refer to :func:`mindspore.ops.multi_margin_loss` for more details. @@ -8808,11 +8811,10 @@ class ApplyKerasMomentum(Primitive): class MultilabelMarginLoss(Primitive): r""" - MultilabelMarginLoss operation. - - Creates a criterion that optimizes a multi-class multi-classification - hinge loss (margin-based loss) between input :math:`x` (a 2D mini-batch `Tensor`) - and output :math:`y` (which is a 2D `Tensor` of target class indices). + Creates a loss criterion that minimizes a margin-based loss for multi-class + classification tasks. + It takes a 2D mini-batch Tensor :math:`x` as input and a 2D + Tensor :math:`y` containing target class indices as output. Refer to :func:`mindspore.ops.multilabel_margin_loss` for more details. @@ -8976,35 +8978,40 @@ class FractionalMaxPool(Primitive): r""" Performs fractional max pooling on the input. - Fractional max pooling is similar to regular max pooling, In regular max pooling, you downsize an - input set by taking the maximum value of smaller N x N subsections of the set (often 2x2), and try - to reduce the set by a factor of N, where N is an integer. Fractional max pooling, means that the - overall reduction ratio N does not have to be an integer. - The sizes of the pooling regions are generated randomly but are fairly uniform. + Fractional max pooling is similar to regular max pooling, but with the added flexibility of + allowing the overall reduction ratio `N` to be a non-integer value. In regular max pooling, + an input set is reduced in size by taking the maximum value of `N x N` (usually 2x2) + subsections of the set, with the goal of reducing the set by a factor of `N`, where `N` is an integer. + + In contrast, fractional max pooling uses randomly generated pool sizes that are fairly uniform in size. .. warning:: "pooling_ratio", currently only supports row and col dimension and should be >= 1.0, the first - and last elements must be 1.0 because we don't allow pooling on batch and channels dimensions. + and last elements must be 1.0 because pooling on batch and channels dimensions is not allowed. Args: - pooling_ratio (list(float)): Decide the shape of output, is a list of floats that has length >= 4. - Pooling ratio for each dimension of value should be >=0, currently only support for row and col - dimension. The first and last elements must be 1.0 because we don't allow pooling on batch and - channels dimensions. - pseudo_random(bool, optional): When set to True, generates the pooling - sequence in a pseudo random fashion, otherwise, in a random fashion. - Check paper Benjamin Graham, Fractional Max-Pooling for difference between pseudo_random and - random. Defaults to False. - overlapping(bool, optional): When set to True, it means when pooling, - the values at the boundary of adjacent pooling cells are used by both cells. - When set to False, the values are not reused. Defaults to False. - deterministic(bool, optional): When set to True, a fixed pooling region - will be used when iterating over a FractionalMaxPool node in the computation graph. Mainly - used in unit test to make FractionalMaxPool deterministic. When set to False, - fixed pool regions will not be used. Defaults to False. - seed(int, optional): If either seed or seed2 are set to be non-zero, the random number generator is - seeded by the given seed. Otherwise, it is seeded by a random seed. Defaults to 0. - seed2(int, optional): An second seed to avoid seed collision. Defaults to 0. + pooling_ratio (list(float)): Decide the shape of output, is a list of float numbers has length >= 4. + Pooling ratio for each dimension of value should not be less than 0, currently only support + for row and col dimension. + pseudo_random(bool, optional): Generate the pooling sequence either randomly or pseudo-randomly. + If the pseudo_random parameter is set to True, the sequence will be generated in a + pseudo-random fashion, otherwise it will be generated randomly. + Refer to `Fractional Max-Pooling `_ + by Benjamin Graham to understand the distinction between the two. + Default: False. + overlapping(bool, optional): When set to True, the values at the boundary of adjacent pooling cells + will be shared by both cells during pooling process. When set to False, the values are not reused. + Default: False. + deterministic(bool, optional): If deterministic is set to True, a fixed pooling region will be used + in the computation graph, ensuring that the FractionalMaxPool is deterministic. + This is often used in unit tests. When set to False, fixed pool regions will not be used. + Default: False. + seed(int, optional): If either seed or seed2 are set to a non-zero value, the random number + generator will be seeded using the specified seed. If neither seed nor seed2 are set, + the generator will be seeded by a random seed. + Default: 0. + seed2(int, optional): The second seed to avoid seed collision. + Default: 0. Inputs: - **x** (Tensor) -The data type must be one of the following types: float32, float64, int32, int64. @@ -9148,11 +9155,10 @@ class FractionalAvgPool(Primitive): r""" Performs fractional avg pooling on the input. - Fractional avg pooling is similar to regular avg pooling, In regular avg pooling, you downsize an - input set by taking the avgrage value of smaller N x N subsections of the set (often 2x2), and try - to reduce the set by a factor of N, where N is an integer. Fractional avg pooling, means that the - overall reduction ratio N does not have to be an integer. In each pooling region, a mean operation - is performed. + Fractional avg pooling is similar to regular avg pooling, but with the added flexibility of + allowing the overall reduction ratio `N` to be a non-integer value. In regular avg pooling, + an input set is reduced in size by taking the average value of `N x N` (usually 2x2) + subsections of the set, with the goal of reducing the set by a factor of `N`, where `N` is an integer. .. warning:: "pooling_ratio", currently only supports row and col dimension and should be >= 1.0, the first @@ -9163,20 +9169,25 @@ class FractionalAvgPool(Primitive): Pooling ratio for each dimension of value should be >=0, currently only support for row and col dimension. The first and last elements must be 1.0 because we don't allow pooling on batch and channels dimensions. - pseudo_random(bool, optional): When set to True, generates the pooling - sequence in a pseudorandom fashion, otherwise, in a random fashion. - Check paper Benjamin Graham, Fractional Max-Pooling for difference between pseudo_random and - random. Defaults to False. - overlapping(bool, optional): When set to True, it means when pooling, - the values at the boundary of adjacent pooling cells are used by both cells. - When set to False, the values are not reused. Defaults to False. - deterministic(bool, optional): When set to True, a fixed pooling region - will be used when iterating over a FractionalAvgPool node in the computation graph. Mainly - used in unit test to make FractionalAvgPool deterministic. When set to False, - fixed pool regions will not be used. Defaults to False. - seed(int, optional): If either seed or seed2 are set to be non-zero, the random number generator - is seeded by the given seed. Otherwise, it is seeded by a random seed. Defaults to 0. - seed2(int, optional): An second seed to avoid seed collision. Defaults to 0. + pseudo_random(bool, optional): Generate the pooling sequence either randomly or pseudo-randomly. + If the pseudo_random parameter is set to True, the sequence will be generated in a + pseudo-random fashion, otherwise it will be generated randomly. + Refer to `Fractional Max-Pooling `_ + by Benjamin Graham to understand the distinction between the two. + Default: False. + overlapping(bool, optional): When set to True, the values at the boundary of adjacent pooling cells + will be shared by both cells during pooling process. When set to False, the values are not reused. + Default: False. + deterministic(bool, optional): If deterministic is set to True, a fixed pooling region will be used + in the computation graph, ensuring that the FractionalAvgPool is deterministic. + This is often used in unit tests. When set to False, fixed pool regions will not be used. + Default: False. + seed(int, optional): If either seed or seed2 are set to a non-zero value, the random number + generator will be seeded using the specified seed. If neither seed nor seed2 are set, + the generator will be seeded by a random seed. + Default: 0. + seed2(int, optional): The second seed to avoid seed collision. + Default: 0. Inputs: - **x** (Tensor) -The data type must be one of the following types: float32, float64, int32, int64.