Question about why `resnet._Stem.pool` have padding
Kitsunetic opened this issue · comments
deeplab-pytorch/libs/models/resnet.py
Line 110 in 4219467
During tests with Deeplab, I found input image size is not divisible by output image size.
The output image size is input_size // 8 + 1
.
For example,
# input: torch.Size([1, 3, 1280, 720])
# output: torch.Size([1, 21, 161, 91])
I found why input size is not divisible by output is because of the padding
in resnet._Stem.pool
layer.
# original
self.pool = nn.MaxPool2d(3, 2, 1, ceil_mode=True)
# result
# input: torch.Size([1, 3, 1280, 720])
# output: torch.Size([1, 21, 161, 91])
# padding = 0
self.pool = nn.MaxPool2d(3, 2, 0, ceil_mode=True)
# result
# input: torch.Size([1, 3, 1280, 720])
# output: torch.Size([1, 21, 160, 90])
I think there is reason why _Stem.pool
have padding, but cannot understand why.
The padding=1
is in the typical ResNet architectures. Indivisible behavior is caused by the ceil_mode=True
and is expected as in DeepLab. To avoid this, please switch to ceil_mode=False
.
OK thank you I understand.
I'll close this issue