pystiche / papers

Reference implementation and replication of prominent NST papers
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

count_include_pad=False has no effect on AutoPadAvgPool2d #257

Closed pmeier closed 3 years ago

pmeier commented 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.