facebookresearch/swav

Changes to standard ResNet

kshen6 opened this issue · 2 comments

Hi authors,
Thanks for making this repository public, it's excellent and easy to use! I had one question about the update you made to the resnet50.py code on line 157. Is there somewhere in the paper that the extra padding is discussed (if there is, I couldn't find it), or can you explain why it is necessary? I am trying to implement SwAV for DenseNets and am wondering if the padding should be added there as well. Thanks so much in advance.

Hi @kshen6

With the padding the implementation is strictly equivalent to that of torchvision since the padding in the first conv is 2 instead of 3 in torchvision.

The padding layer is there because of previous experiments that I did and that required it. You could very well remove the padding layer and use padding=3 instead of padding=2 here:

swav/src/resnet50.py

Lines 173 to 177 in 5e073db

# change padding 3 -> 2 compared to original torchvision code because added a padding layer
num_out_filters = width_per_group * widen
self.conv1 = nn.Conv2d(
3, num_out_filters, kernel_size=7, stride=2, padding=2, bias=False
)

Thank you for the prompt and helpful reply. Closing this thread!