Closed pmeier closed 3 years ago
import torch from torch import nn from pystiche_papers.utils import AutoPadAvgPool2d kernel_size = 3 stride = 1 manual = nn.AvgPool2d(kernel_size=kernel_size, stride=1, padding=1) auto = AutoPadAvgPool2d(kernel_size=kernel_size, stride=1) input = torch.rand(1, 1, 3, 3) assert torch.allclose(auto(input), manual(input)) manual.count_include_pad = False auto.count_include_pad = False assert torch.allclose(auto(input), manual(input)) # fails
Since the padding is performed independent of the pool module, this has to be corrected manually.
Since the padding is performed independent of the pool module, this has to be corrected manually.