Hi,
You can use explicit padding before passing to conv layers (I assumed you are using conv2d). For this, you can use this snippet:
import torch.nn.functonal as F
import torch

x = torch.randn(1, 1, 3, 3)
x = F.pad(x, pad=(1,1,1,1), mode='constant', value=1)
x  # shape [1, 1, 5, 5]


Then you can pass it to a conv layer by not adding any paddings.
Bests