I would like to initialize my model with the first 14 layers of VGG16. A nice solution suggested at https://discuss.pytorch.org/t/how-to-load-part-of-pre-trained-model/1113/3?u=nicholas_wickman does not work for me, because my parameters are not named the same as the model I would like to load from.
My parameters are named like conv1.weight and conv1.bias. VGG’s layers are named like features.0.weight and features.0.bias.
Does anyone have any suggestions?
pretrained_dict = torch.load('VGG_dict.pth')
model_dict = model.state_dict()

# Modification to the dictionary will go here?

model_dict.update(pretrained_dict)
model.load_state_dict(model_dict)