# MaxPool2d¶

\begin{aligned} out(N_i, C_j, h, w) ={} & \max_{m=0, \ldots, kH-1} \max_{n=0, \ldots, kW-1} \text{input}(N_i, C_j, \text{stride[0]} \times h + m, \text{stride[1]} \times w + n) \end{aligned}

padding 非零， 则输入数据会被隐式地在两边用零值进行填充（pad) padding 个点。

• kernel_size (Union[int, Tuple[int, int]]) – 窗的大小。

• stride (Union[int, Tuple[int, int]]) – 窗口的步长。默认值是 kernel_size

• padding (Union[int, Tuple[int, int]]) – 将被隐式填充到两边的零的数量。默认值：0.

Shape:
• Input: $$(N, C, H_{in}, W_{in})$$ or $$(C, H_{in}, W_{in})$$

• Output: $$(N, C, H_{out}, W_{out})$$ or $$(C, H_{out}, W_{out})$$, where

$H_{out} = \left\lfloor\frac{H_{in} + 2 * \text{padding[0]} - \text{dilation[0]} \times (\text{kernel\_size[0]} - 1) - 1}{\text{stride[0]}} + 1\right\rfloor$
$W_{out} = \left\lfloor\frac{W_{in} + 2 * \text{padding[1]} - \text{dilation[1]} \times (\text{kernel\_size[1]} - 1) - 1}{\text{stride[1]}} + 1\right\rfloor$

module. The instance of the MaxPool2d module.

Return type

>>> import numpy as np
>>> m = M.MaxPool2d(kernel_size=3, stride=1, padding=0)
>>> inp = mge.tensor(np.arange(0, 16).astype("float32").reshape(1, 1, 4, 4))
>>> oup = m(inp)
>>> oup.numpy()
array([[[[10., 11.],
[14., 15.]]]], dtype=float32)