megengine.functional.nn.max_pool2d¶
- max_pool2d(inp, kernel_size, stride=None, padding=0)[源代码]¶
对输入张量进行二维最大池化。
更多信息参见
MaxPool2d
。- 参数
inp (
Tensor
) – input tensor of shape \((N, C, H_{\text{in}}, W_{\text{in}})\).kernel_size (
Union
[int
,Tuple
[int
,int
]]) – size of the window used to calculate the max value.stride (
Union
[int
,Tuple
[int
,int
],None
]) – stride of the window. Default value iskernel_size
.padding (
Union
[int
,Tuple
[int
,int
]]) – implicit zero padding added on both sides. Default: 0.
- 返回类型
- 返回
output tensor of shape (N, C, H_{text{out}}, W_{text{out}}).
实际案例
>>> import numpy as np >>> input = Tensor(np.arange(1 * 1 * 3 * 4).astype(np.float32).reshape(1, 1, 3, 4)) >>> F.nn.max_pool2d(input, 2, 1, 0) Tensor([[[[ 5. 6. 7.] [ 9. 10. 11.]]]], device=xpux:0)