Once upon a time, I downloaded the vgg models by jonhson and loaded with torchvision.models.vgg16/19
without a problem.
Lately, I pip
upgraded torchvision modules, and the same old vgg models fail to load, error goes like:
KeyError: 'unexpected key "classifier.1.weight" in state_dict'
Then I check stat_dict
of current upgraded torchvision.models.vgg19
, goes like this:
In [5]: v19.state_dict().keys()
Out[5]: odict_keys([‘features.0.weight’, ‘features.0.bias’, ‘features.2.weight’, ‘features.2.bias’, ‘features.5.weight’, ‘features.5.bias’, ‘features.7.weight’, ‘features.7.bias’, ‘features.10.weight’, ‘features.10.bias’, ‘features.12.weight’, ‘features.12.bias’, ‘features.14.weight’, ‘features.14.bias’, ‘features.16.weight’, ‘features.16.bias’, ‘features.19.weight’, ‘features.19.bias’, ‘features.21.weight’, ‘features.21.bias’, ‘features.23.weight’, ‘features.23.bias’, ‘features.25.weight’, ‘features.25.bias’, ‘features.28.weight’, ‘features.28.bias’, ‘features.30.weight’, ‘features.30.bias’, ‘features.32.weight’, ‘features.32.bias’, ‘features.34.weight’, ‘features.34.bias’, ‘classifier.0.weight’, ‘classifier.0.bias’, ‘classifier.3.weight’, ‘classifier.3.bias’, ‘classifier.6.weight’, ‘classifier.6.bias’])
Indeed, no such a key classifier.1.weight
, so the new torchvision
models made some changes to the stat_dict
?