mindspore.mint.nn.AvgPool2d

查看源文件
class mindspore.mint.nn.AvgPool2d(kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True, divisor_override=None)[源代码]

对输入张量应用二维平均池化,可视为二维输入平面的组合。

更多参考详见 mindspore.mint.nn.functional.avg_pool2d()

支持平台:

Ascend

样例:

>>> import numpy as np
>>> from mindspore import Tensor, mint
>>> from mindspore import dtype as mstype
>>> x = Tensor(np.arange(1 * 3 * 3 * 4).reshape(1, 3, 3, 4), mstype.float32)
>>> m =  mint.nn.AvgPool2d(x, kernel_size=2, stride=1)
>>> output = m(x)
>>> print(output)
[[[[ 2.5   3.5   4.5]
   [ 6.5   7.5   8.5]]
  [[14.5  15.5  16.5]
   [18.5  19.5  20.5]]
  [[26.5  27.5  28.5]
   [30.5  31.5  32.5]]]]