Hi,
The simplest solution I can think of is that you create a wrapper class around available nn.Conv2d but instead of passing any paddings to nn.Conv2d object, you use explicit padding by using torch.nn.functional.pad.
Following post explains how to use explicit padding and wrapping it into another class that contains nn.Conv2d would pretty much easy.
  
    
    
    Same padding equivalent in Pytorch 
  
  
    Hi, 
PyTorch does not support same padding the way Keras does, but still you can manage it easily using explicit padding before passing the tensor to convolution layer. Here, symmetric padding is not possible so by padding only one side, in your case, top bottom of tensor, we can achieve same padding. 
import torch
import torch.nn.functional as F

x = torch.randn(64, 32, 100, 20)
x = F.pad(x, (0, 0, 2, 1))  # [left, right, top, bot]
nn.Conv2d(32, 32, (4, 1))(x).shape


Please see these post abou…
  


Bests