d-li14 / mobilenetv3.pytorch

74.3% MobileNetV3-Large and 67.2% MobileNetV3-Small model on ImageNet

Home Page:https://arxiv.org/abs/1905.02244

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

missing keys for mobilenet v3-large?

ktaebum opened this issue · comments

Hello!

First of all, thanks for your great implementation of MobileNetV3

However, when I try to use your pretrained model (large model),

it raises error as

RuntimeError: Error(s) in loading state_dict for MobileNetV3:
        Missing key(s) in state_dict: "classifier.0.weight", "classifier.0.bias", "classifier.3.weight", "classifier.3.bias".
        Unexpected key(s) in state_dict: "classifier.1.weight", "classifier.1.bias", "classifier.5.weight", "classifier.5.bias".

Is there any difference between current implementation and pretrained checkpoint?

I'm getting the same error.

the same error

commented

I got the same error and tried to assign them manually. Looks like it works, but I don't know if this is the right approach...

state_dict = torch.load('pretrained/mobilenetv3-large-657e7b3d.pth')

state_dict["classifier.0.weight"] = state_dict["classifier.1.weight"]
del state_dict["classifier.1.weight"]

state_dict["classifier.0.bias"] = state_dict["classifier.1.bias"]
del state_dict["classifier.1.bias"]

state_dict["classifier.3.weight"] = state_dict["classifier.5.weight"]
del state_dict["classifier.5.weight"]

state_dict["classifier.3.bias"] = state_dict["classifier.5.bias"]
del state_dict["classifier.5.bias"] 

net_large.load_state_dict(                                                                                        
# torch.load('pretrained/mobilenetv3-large-657e7b3d.pth')
state_dict
)  

same error, I think maybe due to different pytorch versions.

@d-li14 could you share the version of pytorch that you were using?

the same error, please update the given pth file. Thank you.

@sngyo provides the right workaround, also refer to #2. However, I will update the network structure and pre-trained models according to the revised MobileNetV3 paper soon. Stay tuned.

The up-to-date release provides bug-free and stronger models now.

i find that the large pth weight key and network model key is not corresponding:
image