torch.nn.MaxPool2d(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)
Parameters
1 kernel_size – the size of the window to take a max over 2 stride – the stride of the window. Default value is kernel_size 3 padding – implicit zero padding to be added on both sides 4 dilation – a parameter that controls the stride of elements in the window 5 return_indices – if True, will return the max indices along with the outputs. Useful for torch.nn.MaxUnpool2d later 6 ceil_mode – when True, will use ceil instead of floor to compute the output shape
Shape
Examples
[32, 64, 112, 112] ——> [32, 64, 56, 56]
1 import torch 2 import torch.nn as nn 3 4 pool1 = nn.MaxPool2d(2, stride=2) 5 print(pool1(input1).size())
[32, 64, 112, 112] ——> [32, 64, 111, 111]
1 import torch 2 import torch.nn as nn 3 4 pool1 = nn.MaxPool2d(2, stride=1) 5 print(pool1(input1).size())