I’m new to pytorch and I found that the padding mode of conv2d is not zero padding in the following code:
import torch
import torch.nn.functional as F
a = torch.tensor([[[[1,2,3,4],[4,5,6,7],[7,8,9,10]]]])
weight = torch.ones((1,1,3,3)).to(torch.long)
F.conv2d(a, weight, stride=1, padding=1)
The output is:
tensor([[[[12, 21, 27, 20],
[27, 45, 54, 39],
[24, 39, 45, 32]]]])
When without padding, the output is:
tensor([[[[45, 54]]]])
I read from the document that the default padding mode is “zero”, which means use zero to pad output tensors. So is there anything that changes the mode?