Hello community.
I am writting a keras model into Pytorch but i have a big trouble with creating in pytorch this 3 keras layers
MaxPooling2D(pool_size=(2, 2), strides=(1, 1), padding='same')
MaxPooling2D(pool_size=(3, 3), padding='same', strides=(2, 2))
Conv2D(filters=12, kernel_size=(3, 3), activation='relu', padding='same', strides=(2, 2))

For the first one, i have fund that
x = torch.nn.MaxPool2d(kernel_size=3, stride=1, padding=1)(x)
x = [:, :, 1:, 1:]

gives a correct result, I got the same as using keras model.
For the las one i have used this wrapped and it works
class Conv2dSamePadding(nn.Conv2d):
    def __init__(self,*args,**kwargs):
        super(Conv2dSamePadding, self).__init__(*args, **kwargs)
        self.zero_pad_2d = nn.ZeroPad2d(reduce(__add__,
            [(k // 2 + (k - 2 * (k // 2)) - 1, k // 2) for k in self.kernel_size[::-1]]))

But can not with the second maxpooling.
Also i would appreciate a better general solution to my problem to solver the ‘padding issue’
Thanks