-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Closed
Description
Dimension mismatch error while loading a pretrained Inception v3
Environment
0.2.1 with Anaconda, python3.6, Ubuntu 16
code
from torchvision.models.inception import Inception3, inception_v3
model = inception_v3(num_classes=1, pretrained=True, aux_logits=False)
error
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-31-e0b4dcd6b958> in <module>()
----> 1 model = inception_v3(num_classes=1, pretrained=True, aux_logits=False)
/anaconda3/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/models/inception.py in inception_v3(pretrained, **kwargs)
25 kwargs['transform_input'] = True
26 model = Inception3(**kwargs)
---> 27 model.load_state_dict(model_zoo.load_url(model_urls['inception_v3_google']))
28 return model
29
/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py in load_state_dict(self, state_dict, strict)
719 if len(error_msgs) > 0:
720 raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
--> 721 self.__class__.__name__, "\n\t".join(error_msgs)))
722
723 def parameters(self):
RuntimeError: Error(s) in loading state_dict for Inception3:
Unexpected key(s) in state_dict: "AuxLogits.conv0.conv.weight", "AuxLogits.conv0.bn.weight", "AuxLogits.conv0.bn.bias", "AuxLogits.conv0.bn.running_mean", "AuxLogits.conv0.bn.running_var", "AuxLogits.conv1.conv.weight", "AuxLogits.conv1.bn.weight", "AuxLogits.conv1.bn.bias", "AuxLogits.conv1.bn.running_mean", "AuxLogits.conv1.bn.running_var", "AuxLogits.fc.weight", "AuxLogits.fc.bias".
While copying the parameter named "fc.weight", whose dimensions in the model are torch.Size([1, 2048]) and whose dimensions in the checkpoint are torch.Size([1000, 2048]).
While copying the parameter named "fc.bias", whose dimensions in the model are torch.Size([1]) and whose dimensions in the checkpoint are torch.Size([1000]).
Metadata
Metadata
Assignees
Labels
No labels