Load pretrained resen101 model

I rebuilt resnet101 code:

self.layer3 = self._make_layer(block, norm_layer, 256, layers[2],
                                       inplace, stride=1,
                                       bn_eps=bn_eps, bn_momentum=bn_momentum)
self.layer4 = self._make_layer(block, norm_layer, 512, layers[3],
                                       inplace, stride=1,
                                       bn_eps=bn_eps, bn_momentum=bn_momentum)

pytorch code:


self.layer3 = self._make_layer(block, planes[2], layers[2], stride=2, groups=groups, 
                          norm_layer=norm_layer)
self.layer4 = self._make_layer(block, planes[3], layers[3], stride=2, groups=groups, 
                          norm_layer=norm_layer)

note : my code stride = 1, I want to downsample the input image by 1/8,or set dilation = 3 in nn.conv2d(). Can I still use pretrained weight?

thanks!!!

You can since stride/dilations does not change size of the filters, however results may not to be good and for sure not as good as filers are not optimized for that size.

thanks, I rebuilt resnet101 is segmentation model backbone,so don`t use pretrained ‘fc’ layer weight, load_state_dict(pretrained model) Will it report an error?

it has an additional argument which is strict, if you set it to False it matches as many layers as possible without reporting errors. If you set it to True it will require a perfect matching.