Unable to load model state after modifications (missing key(s) in state_dict)

Given a model, say resnet18 from torchvision, we may have a collection of pretrained weights we’d like to load. However, in some cases, that model may have been subject to modifications, say the removal of fc and avg_pool of resnet18, and as such it is now seemingly not possible to load the weights due to the rise of “missing key(s)” exception.

Is there a way to still be able to load the weights for the existing layers despite the removal of some?

You could filter out the unnecessary parameters in your state_dict.
Have a look at this post.