Pytorch online documentation says “if padding
is non-zero, then the input is implicitly zero-padded on both sides for padding
number of points”.
But it is not true in my experiment.
The code is here:
import torch
import torch.nn as nn
import numpy as np
pool = nn.MaxPool2d(3, stride=1, padding=1)
x = torch.ones((1, 1, 3, 3))
x *= -1
print('=========== x ===========')
print(x)
y = pool(x)
print('=========== y ===========')
print(y)
The outputs are:
=========== x ===========
tensor([[[[-1., -1., -1.],
[-1., -1., -1.],
[-1., -1., -1.]]]])
=========== y ===========
tensor([[[[-1., -1., -1.],
[-1., -1., -1.],
[-1., -1., -1.]]]])
If it is zero-padded, then the outputs should contain zeros since 0 > -1.
So which is correct, the documentation or the code?