mindspore/docs/api/api_python/mint/mindspore.mint.nn.AdaptiveM...

42 lines
2.1 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.mint.nn.AdaptiveMaxPool2d
=====================================
.. py:class:: mindspore.mint.nn.AdaptiveMaxPool2d(output_size, return_indices=False)
对输入Tensor提供二维自适应最大池化操作。对于输入任何格式指定输出的格式都为H * W。但是输入和输出特征的数目不会变化。
输入和输出数据格式可以是"NCHW"和"CHW"。N是批处理大小C是通道数H是特征高度W是特征宽度。运算如下
.. math::
\begin{align}
h_{start} &= floor(i * H_{in} / H_{out})\\
h_{end} &= ceil((i + 1) * H_{in} / H_{out})\\
w_{start} &= floor(j * W_{in} / W_{out})\\
w_{end} &= ceil((j + 1) * W_{in} / W_{out})\\
Output(i,j) &= {\max Input[h_{start}:h_{end}, w_{start}:w_{end}]}
\end{align}
.. note::
- KBK模式下 `output_size` 不支持mutable类型。
- Atlas训练系列产品不支持反向传播。
参数:
- **output_size** (Union[int, tuple]) - 输出特征图的size。 `output_size` 可以为二元tuple表示 :math:`(H, W)`。或者是单个int表示 :math:`(H, H)`:math:`H`:math:`W` 可以是int或None如果是None则意味着输出的size与输入相同。
- **return_indices** (bool可选) - 如果为 ``True`` ,输出最大值的索引,默认值为 ``False``
输入:
- **input** (Tensor) - AdaptiveMaxPool2d的输入为三维或四维的Tensor数据类型为float16、float32或者float64。
输出:
Tensor数据类型与 `input` 相同。
输出的shape为 :math:`input\_shape[:len(input\_shape) - len(out\_shape)] + out\_shape`
异常:
- **TypeError** - `input` 不是Tensor。
- **TypeError** - `input` 中的数据不是float16、float32、float64。
- **TypeError** - `output_size` 不是int或者tuple。
- **TypeError** - `return_indices` 不是bool。
- **ValueError** - `output_size` 是tuple但大小不是2。
- **ValueError** - `input` 的维度不是CHW或者NCHW。