d-li14 / mobilenetv3.pytorch

74.3% MobileNetV3-Large and 67.2% MobileNetV3-Small model on ImageNet
https://arxiv.org/abs/1905.02244
MIT License
519 stars 125 forks source link

RuntimeError: Error(s) in loading state_dict for MobileNetV3: #16

Closed GHLab closed 4 years ago

GHLab commented 4 years ago

Thank you for your work. Pull all source and create test.py and run it.

import torch
from mobilenetv3 import mobilenetv3_large, mobilenetv3_small

net_large = mobilenetv3_large()
net_small = mobilenetv3_small()

net_large.load_state_dict(torch.load('pretrained/mobilenetv3-large-1cd25616.pth'))
net_small.load_state_dict(torch.load('pretrained/mobilenetv3-small-55df8e1f.pth'))

But below error was occurred.

Traceback (most recent call last): File "test.py", line 7, in net_large.load_state_dict(torch.load('pretrained/mobilenetv3-large-1cd25616.pth')) File "/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py", line 839, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for MobileNetV3: Missing key(s) in state_dict: "classifier.2.weight", "classifier.2.bias". Unexpected key(s) in state_dict: "classifier.3.weight", "classifier.3.bias".

Could check this?

d-li14 commented 4 years ago

fixed