mindspore/docs/api/api_python/nn/mindspore.nn.AdaptiveMaxPoo...

41 lines
1.9 KiB
ReStructuredText
Raw 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.nn.AdaptiveMaxPool2d
=================================
.. py:class:: mindspore.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::
Ascend平台input输入仅支持float16类型。
参数:
- **output_size** (Union[int, tuple]) - 输出特征图的尺寸为H * W。可以是int类型的H和W组成的tuple也可以为一个int值代表相同H和W或None如果是None则意味着输出大小与输入相同。
- **return_indices** (bool) - 如果为True输出最大值的索引默认值为False。
输入:
- **input** (Tensor) - AdaptiveMaxPool2d的输入为三维或四维的Tensor数据类型为float16、float32或者float64。
输出:
Tensor数据类型与 `input` 相同。
输出的shape为 `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。