Ah my apologises, I should’ve phrased the last statement more clearly. I meant to try the for key, value in state_dict
expression for your original torch.save
object. It makes sense it requires model_state_dict
as that’s the key we use to save the model’s state_dict
!
When loading the model
you’re using the right object. It seems the issue is that your state_dict
has the wrong shape for the layer called classifier.6
The issue seems that your output shape should be of shape [1000, 4096]
whereas yours is [27, 4096]
I assume you’re trying to use VGG16 for classification but you only have 27 classes rather than the default 1000 classes? If so, it seems you just need to change the output shape to be for 27 classes and the model loading should be fine!