2022-05-28 12:01:53 +08:00
|
|
|
|
mindspore.nn.AdaptiveMaxPool2d
|
|
|
|
|
|
=================================
|
|
|
|
|
|
|
2022-05-31 14:35:52 +08:00
|
|
|
|
.. py:class:: mindspore.nn.AdaptiveMaxPool2d(output_size, return_indices=False)
|
2022-05-28 12:01:53 +08:00
|
|
|
|
|
2022-09-06 16:52:57 +08:00
|
|
|
|
对输入Tensor,提供二维自适应最大池化操作。对于输入任何格式,指定输出的格式都为H * W。但是输入和输出特征的数目不会变化。
|
2022-05-31 14:35:52 +08:00
|
|
|
|
|
2022-06-13 11:25:40 +08:00
|
|
|
|
输入和输出数据格式可以是"NCHW"和"CHW"。N是批处理大小,C是通道数,H是特征高度,W是特征宽度。运算如下:
|
2022-05-28 12:01:53 +08:00
|
|
|
|
|
|
|
|
|
|
.. 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}
|
|
|
|
|
|
|
2022-07-06 10:49:16 +08:00
|
|
|
|
.. note::
|
|
|
|
|
|
Ascend平台input_x输入仅支持float16类型。
|
|
|
|
|
|
|
2022-07-22 16:25:38 +08:00
|
|
|
|
参数:
|
|
|
|
|
|
- **output_size** (Union[int, tuple]) - 输出特征图的尺寸为H * W。可以是int类型的H和W组成的tuple,也可以为一个int值,代表相同H和W,或None,如果是None,则意味着输出大小与输入相同。
|
|
|
|
|
|
- **return_indices** (bool) - 如果为True,输出最大值的索引,默认值为False。
|
2022-05-28 12:01:53 +08:00
|
|
|
|
|
2022-07-22 16:25:38 +08:00
|
|
|
|
输入:
|
|
|
|
|
|
- **input_x** (Tensor) - AdaptiveMaxPool2d的输入,为三维或四维的Tensor,数据类型为float16、float32或者float64。
|
2022-05-28 12:01:53 +08:00
|
|
|
|
|
2022-07-22 16:25:38 +08:00
|
|
|
|
输出:
|
|
|
|
|
|
Tensor,数据类型与 `input_x` 相同。
|
|
|
|
|
|
输出的shape为 `input_x_shape[:len(input_x_shape) - len(out_shape)] + out_shape` 。
|
2022-05-28 12:01:53 +08:00
|
|
|
|
|
2022-07-22 16:25:38 +08:00
|
|
|
|
异常:
|
|
|
|
|
|
- **TypeError** - `input_x` 不是Tensor。
|
|
|
|
|
|
- **TypeError** - `input_x` 中的数据不是float16, float32, float64.
|
|
|
|
|
|
- **TypeError** - `output_size` 不是int或者tuple。
|
|
|
|
|
|
- **TypeError** - `return_indices` 不是bool。
|
|
|
|
|
|
- **ValueError** - `output_size` 是tuple,但大小不是2。
|
|
|
|
|
|
- **ValueError** - `input_x` 的维度不是CHW或者NCHW。
|