How to transfer weights (initialize) with a custom pretrained model?

I am training a model on my custom dataset using the repository of the author. They have provided pretrained models on UCF101. Since my dataset has a different set of classes I am not able to directly resume the training but I need to transfer weights from this pretrained file to initiate my layers so that I can train on my dataset with a different number of classes. In Caffe this used to be very simple and I was able to do it by just passing the file as a parameter to some function (for as long as the architecture was the same)
I see a lot of documentation on how to use pretrained model libraries but not with custom models.


You could have a try on model.load_state_dict with strict=False, and define the last fc layer for a different number of classes in addition. load_state_dict