$out(N_i, C_j, h, w) = \frac{1}{kH * kW} \sum_{m=0}^{kH-1} \sum_{n=0}^{kW-1} input(N_i, C_j, stride[0] \times h + m, stride[1] \times w + n)$

kernel_sizestride 可以从输入输出的形状推断：

• padding: (0, 0)

• stride: (floor(IH / OH), floor(IW / OW))

• kernel_size: (IH - (OH - 1) * stride_h, IW - (OW - 1) * stride_w)

oshp (Union[Tuple[int, int], int, Tensor]) – the target output shape of the image of the form Height * Width. Can be tuple (H, W) or a single H for a square image H * H.

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

• Output: $$(N, C, D_{out}, H_{out}, W_{out})$$ or $$(C, D_{out}, H_{out}, W_{out})$$, where $$(D_{out}, H_{out}, W_{out})=\text{output\_shape}$$.

module. The instance of the AdaptiveAvgPool2d module.

Return type

>>> import numpy as np
>>> m = M.AdaptiveAvgPool2d((2, 2))
>>> inp = mge.tensor(np.arange(0, 16).astype("float32").reshape(1, 1, 4, 4))
>>> oup = m(inp)
>>> oup.numpy()
array([[[[ 2.5,  4.5],
[10.5, 12.5]]]], dtype=float32)