Padding and stride for transfer learning

I want to transfer learning from vgg16 pretrained layer to a layer in a new model
is it compulsory to use the same stride and padding values like in the original (pretrained) layer?

say I wan to transfer learning from the second conv layer in vgg16 that looks as below:
nn.Conv2D(64, 64, kernel_size=(3,3),padding=(1,1), stride=1)
and my new layer:
nn.Conv2D(64, 64, kernel_size=(3,3),padding=0, stride=1)
can I still transfer learning from A to B?

Yes you should still use the same padding and stride because that will change the output size if you mess around with them. The pretrained weights are trained on a specific size so other sizes might mess up the training.

thanks for your ansewr.

say I want to have an output layer that has the half size of the original (pretrained) one. does not this allow me to tweak the stride value to 2 instead of the oraginally value 1 ?
you also mentioned that pretrained layers are trained to deal with specific spatial size. does this mean if vgg16 for example was trained on 224 by 224 images then we can input only this image size?

Yes you can tweak the stride. No you do not have to input a 224 by 224 image. You can input any image size but the performance might not be the same as you expect because the weights won’t match to the image size.