d-li14 / mobilenetv3.pytorch Goto Github PK
View Code? Open in Web Editor NEW74.3% MobileNetV3-Large and 67.2% MobileNetV3-Small model on ImageNet
Home Page: https://arxiv.org/abs/1905.02244
License: MIT License
74.3% MobileNetV3-Large and 67.2% MobileNetV3-Small model on ImageNet
Home Page: https://arxiv.org/abs/1905.02244
License: MIT License
Ur code only add the output with input when the stride is 1.
How about 2?
Hi, Thanks for your sharing an awesome work,
This is not an issue, just like a question, please help:
I would like to add FPN head to your mnetv3 backbone. I see that FPN requires the consecutive double size of the return layers ( 32 -> 64 -> 128...). But the size of the output layers of mobilenetv3 are 16 ->24 ->40 ,... which do not adopt the rule. Do you have any comments?
anyway, if modify the net, I can successfully build but with worse accuracy. Thank you.
The official tensor-flow implementation is based on using depth wise convolutions
https://github.com/frotms/MobilenetV3-Tensorflow/blob/master/mobilenet_v3.py
Which seems to be missing in your architecture.
Can you please confirm that?
HI,
Thanks for the effort working on this. I am using the ImageNet validation dataset, which contains 50000 images, to conduct the validation for the large network. However, my accuracy on the validation set cannot reach 72%. Mine only reaches 70%. I wonder do you have any additional pre-processing for the input image during validation besides normalization? Such as cropping?
Thank you
Would you please share the image loading code? Thank you!
import torch
from mobilenetv3 import mobilenetv3_small
net_small = mobilenetv3_small()
net_small.load_state_dict(torch.load('mobilenetv3-small-c7eb32fe.pth'))
net_small.eval()
x = torch.randn(2,3,224,224)
net_small(x)
!!!Segmentation fault (core dumped) in line net_small(x)
torch.version '0.4.1'
Thank you for your code and pretrained model, I am a newbie in Pytorch and I have a question for the architecture. According to Pytorch document, Sequential is used to add modules.
However, in the classifier part, sequential() is empty inside. (classifier[1], classifier[4], classifier[5])
Could you please explain for me about that.
Thank you very much
Get errors when trying to load the pretrained models. In particular, it looks like the state_dict for the small model is actually based on the large model.
For the large model:
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".
For the small model:
RuntimeError: Error(s) in loading state_dict for MobileNetV3:
Missing key(s) in state_dict: "features.1.conv.3.fc.0.weight", "features.1.conv.3.fc.0.bias", "features.1.conv.3.fc.2.weight", "features.1.conv.3.fc.2.bias", "features.7.conv.5.fc.0.weight", "features.7.conv.5.fc.0.bias", "features.7.conv.5.fc.2.weight", "features.7.conv.5.fc.2.bias", "features.8.conv.5.fc.0.weight", "features.8.conv.5.fc.0.bias", "features.8.conv.5.fc.2.weight", "features.8.conv.5.fc.2.bias", "features.9.conv.5.fc.0.weight", "features.9.conv.5.fc.0.bias", "features.9.conv.5.fc.2.weight", "features.9.conv.5.fc.2.bias", "features.10.conv.5.fc.0.weight", "features.10.conv.5.fc.0.bias", "features.10.conv.5.fc.2.weight", "features.10.conv.5.fc.2.bias", "conv.1.fc.0.weight", "conv.1.fc.0.bias", "conv.1.fc.2.weight", "conv.1.fc.2.bias", "classifier.0.weight", "classifier.0.bias", "classifier.1.running_mean", "classifier.1.running_var", "classifier.3.weight", "classifier.3.bias", "classifier.4.weight", "classifier.4.bias", "classifier.4.running_mean", "classifier.4.running_var".
Unexpected key(s) in state_dict: "features.12.conv.0.weight", "features.12.conv.1.weight", "features.12.conv.1.bias", "features.12.conv.1.running_mean", "features.12.conv.1.running_var", "features.12.conv.1.num_batches_tracked", "features.12.conv.3.weight", "features.12.conv.4.weight", "features.12.conv.4.bias", "features.12.conv.4.running_mean", "features.12.conv.4.running_var", "features.12.conv.4.num_batches_tracked", "features.12.conv.5.fc.0.weight", "features.12.conv.5.fc.0.bias", "features.12.conv.5.fc.2.weight", "features.12.conv.5.fc.2.bias", "features.12.conv.7.weight", "features.12.conv.8.weight", "features.12.conv.8.bias", "features.12.conv.8.running_mean", "features.12.conv.8.running_var", "features.12.conv.8.num_batches_tracked", "features.13.conv.0.weight", "features.13.conv.1.weight", "features.13.conv.1.bias", "features.13.conv.1.running_mean", "features.13.conv.1.running_var", "features.13.conv.1.num_batches_tracked", "features.13.conv.3.weight", "features.13.conv.4.weight", "features.13.conv.4.bias", "features.13.conv.4.running_mean", "features.13.conv.4.running_var", "features.13.conv.4.num_batches_tracked", "features.13.conv.5.fc.0.weight", "features.13.conv.5.fc.0.bias", "features.13.conv.5.fc.2.weight", "features.13.conv.5.fc.2.bias", "features.13.conv.7.weight", "features.13.conv.8.weight", "features.13.conv.8.bias", "features.13.conv.8.running_mean", "features.13.conv.8.running_var", "features.13.conv.8.num_batches_tracked", "features.14.conv.0.weight", "features.14.conv.1.weight", "features.14.conv.1.bias", "features.14.conv.1.running_mean", "features.14.conv.1.running_var", "features.14.conv.1.num_batches_tracked", "features.14.conv.3.weight", "features.14.conv.4.weight", "features.14.conv.4.bias", "features.14.conv.4.running_mean", "features.14.conv.4.running_var", "features.14.conv.4.num_batches_tracked", "features.14.conv.5.fc.0.weight", "features.14.conv.5.fc.0.bias", "features.14.conv.5.fc.2.weight", "features.14.conv.5.fc.2.bias", "features.14.conv.7.weight", "features.14.conv.8.weight", "features.14.conv.8.bias", "features.14.conv.8.running_mean", "features.14.conv.8.running_var", "features.14.conv.8.num_batches_tracked", "features.15.conv.0.weight", "features.15.conv.1.weight", "features.15.conv.1.bias", "features.15.conv.1.running_mean", "features.15.conv.1.running_var", "features.15.conv.1.num_batches_tracked", "features.15.conv.3.weight", "features.15.conv.4.weight", "features.15.conv.4.bias", "features.15.conv.4.running_mean", "features.15.conv.4.running_var", "features.15.conv.4.num_batches_tracked", "features.15.conv.5.fc.0.weight", "features.15.conv.5.fc.0.bias", "features.15.conv.5.fc.2.weight", "features.15.conv.5.fc.2.bias", "features.15.conv.7.weight", "features.15.conv.8.weight", "features.15.conv.8.bias", "features.15.conv.8.running_mean", "features.15.conv.8.running_var", "features.15.conv.8.num_batches_tracked", "classifier.5.weight", "classifier.5.bias".
size mismatch for features.2.conv.0.weight: copying a param with shape torch.Size([64, 16, 1, 1]) from checkpoint, the shape in current model is torch.Size([72, 16, 1, 1]).
size mismatch for features.2.conv.1.weight: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([72]).
size mismatch for features.2.conv.1.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([72]).
size mismatch for features.2.conv.1.running_mean: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([72]).
size mismatch for features.2.conv.1.running_var: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([72]).
size mismatch for features.2.conv.3.weight: copying a param with shape torch.Size([64, 1, 3, 3]) from checkpoint, the shape in current model is torch.Size([72, 1, 3, 3]).
size mismatch for features.2.conv.4.weight: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([72]).
size mismatch for features.2.conv.4.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([72]).
size mismatch for features.2.conv.4.running_mean: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([72]).
size mismatch for features.2.conv.4.running_var: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([72]).
size mismatch for features.2.conv.7.weight: copying a param with shape torch.Size([24, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([24, 72, 1, 1]).
size mismatch for features.3.conv.0.weight: copying a param with shape torch.Size([72, 24, 1, 1]) from checkpoint, the shape in current model is torch.Size([88, 24, 1, 1]).
size mismatch for features.3.conv.1.weight: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([88]).
size mismatch for features.3.conv.1.bias: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([88]).
size mismatch for features.3.conv.1.running_mean: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([88]).
size mismatch for features.3.conv.1.running_var: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([88]).
size mismatch for features.3.conv.3.weight: copying a param with shape torch.Size([72, 1, 3, 3]) from checkpoint, the shape in current model is torch.Size([88, 1, 3, 3]).
size mismatch for features.3.conv.4.weight: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([88]).
size mismatch for features.3.conv.4.bias: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([88]).
size mismatch for features.3.conv.4.running_mean: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([88]).
size mismatch for features.3.conv.4.running_var: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([88]).
size mismatch for features.3.conv.7.weight: copying a param with shape torch.Size([24, 72, 1, 1]) from checkpoint, the shape in current model is torch.Size([24, 88, 1, 1]).
size mismatch for features.4.conv.0.weight: copying a param with shape torch.Size([72, 24, 1, 1]) from checkpoint, the shape in current model is torch.Size([96, 24, 1, 1]).
size mismatch for features.4.conv.1.weight: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.4.conv.1.bias: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.4.conv.1.running_mean: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.4.conv.1.running_var: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.4.conv.3.weight: copying a param with shape torch.Size([72, 1, 5, 5]) from checkpoint, the shape in current model is torch.Size([96, 1, 5, 5]).
size mismatch for features.4.conv.4.weight: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.4.conv.4.bias: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.4.conv.4.running_mean: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.4.conv.4.running_var: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.4.conv.5.fc.0.weight: copying a param with shape torch.Size([18, 72]) from checkpoint, the shape in current model is torch.Size([24, 96]).
size mismatch for features.4.conv.5.fc.0.bias: copying a param with shape torch.Size([18]) from checkpoint, the shape in current model is torch.Size([24]).
size mismatch for features.4.conv.5.fc.2.weight: copying a param with shape torch.Size([72, 18]) from checkpoint, the shape in current model is torch.Size([96, 24]).
size mismatch for features.4.conv.5.fc.2.bias: copying a param with shape torch.Size([72]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.4.conv.7.weight: copying a param with shape torch.Size([40, 72, 1, 1]) from checkpoint, the shape in current model is torch.Size([40, 96, 1, 1]).
size mismatch for features.5.conv.0.weight: copying a param with shape torch.Size([120, 40, 1, 1]) from checkpoint, the shape in current model is torch.Size([240, 40, 1, 1]).
size mismatch for features.5.conv.1.weight: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.5.conv.1.bias: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.5.conv.1.running_mean: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.5.conv.1.running_var: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.5.conv.3.weight: copying a param with shape torch.Size([120, 1, 5, 5]) from checkpoint, the shape in current model is torch.Size([240, 1, 5, 5]).
size mismatch for features.5.conv.4.weight: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.5.conv.4.bias: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.5.conv.4.running_mean: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.5.conv.4.running_var: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.5.conv.5.fc.0.weight: copying a param with shape torch.Size([30, 120]) from checkpoint, the shape in current model is torch.Size([60, 240]).
size mismatch for features.5.conv.5.fc.0.bias: copying a param with shape torch.Size([30]) from checkpoint, the shape in current model is torch.Size([60]).
size mismatch for features.5.conv.5.fc.2.weight: copying a param with shape torch.Size([120, 30]) from checkpoint, the shape in current model is torch.Size([240, 60]).
size mismatch for features.5.conv.5.fc.2.bias: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.5.conv.7.weight: copying a param with shape torch.Size([40, 120, 1, 1]) from checkpoint, the shape in current model is torch.Size([40, 240, 1, 1]).
size mismatch for features.6.conv.0.weight: copying a param with shape torch.Size([120, 40, 1, 1]) from checkpoint, the shape in current model is torch.Size([240, 40, 1, 1]).
size mismatch for features.6.conv.1.weight: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.6.conv.1.bias: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.6.conv.1.running_mean: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.6.conv.1.running_var: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.6.conv.3.weight: copying a param with shape torch.Size([120, 1, 5, 5]) from checkpoint, the shape in current model is torch.Size([240, 1, 5, 5]).
size mismatch for features.6.conv.4.weight: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.6.conv.4.bias: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.6.conv.4.running_mean: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.6.conv.4.running_var: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.6.conv.5.fc.0.weight: copying a param with shape torch.Size([30, 120]) from checkpoint, the shape in current model is torch.Size([60, 240]).
size mismatch for features.6.conv.5.fc.0.bias: copying a param with shape torch.Size([30]) from checkpoint, the shape in current model is torch.Size([60]).
size mismatch for features.6.conv.5.fc.2.weight: copying a param with shape torch.Size([120, 30]) from checkpoint, the shape in current model is torch.Size([240, 60]).
size mismatch for features.6.conv.5.fc.2.bias: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([240]).
size mismatch for features.6.conv.7.weight: copying a param with shape torch.Size([40, 120, 1, 1]) from checkpoint, the shape in current model is torch.Size([40, 240, 1, 1]).
size mismatch for features.7.conv.0.weight: copying a param with shape torch.Size([240, 40, 1, 1]) from checkpoint, the shape in current model is torch.Size([120, 40, 1, 1]).
size mismatch for features.7.conv.1.weight: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([120]).
size mismatch for features.7.conv.1.bias: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([120]).
size mismatch for features.7.conv.1.running_mean: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([120]).
size mismatch for features.7.conv.1.running_var: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([120]).
size mismatch for features.7.conv.3.weight: copying a param with shape torch.Size([240, 1, 3, 3]) from checkpoint, the shape in current model is torch.Size([120, 1, 5, 5]).
size mismatch for features.7.conv.4.weight: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([120]).
size mismatch for features.7.conv.4.bias: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([120]).
size mismatch for features.7.conv.4.running_mean: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([120]).
size mismatch for features.7.conv.4.running_var: copying a param with shape torch.Size([240]) from checkpoint, the shape in current model is torch.Size([120]).
size mismatch for features.7.conv.7.weight: copying a param with shape torch.Size([80, 240, 1, 1]) from checkpoint, the shape in current model is torch.Size([48, 120, 1, 1]).
size mismatch for features.7.conv.8.weight: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([48]).
size mismatch for features.7.conv.8.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([48]).
size mismatch for features.7.conv.8.running_mean: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([48]).
size mismatch for features.7.conv.8.running_var: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([48]).
size mismatch for features.8.conv.0.weight: copying a param with shape torch.Size([200, 80, 1, 1]) from checkpoint, the shape in current model is torch.Size([144, 48, 1, 1]).
size mismatch for features.8.conv.1.weight: copying a param with shape torch.Size([200]) from checkpoint, the shape in current model is torch.Size([144]).
size mismatch for features.8.conv.1.bias: copying a param with shape torch.Size([200]) from checkpoint, the shape in current model is torch.Size([144]).
size mismatch for features.8.conv.1.running_mean: copying a param with shape torch.Size([200]) from checkpoint, the shape in current model is torch.Size([144]).
size mismatch for features.8.conv.1.running_var: copying a param with shape torch.Size([200]) from checkpoint, the shape in current model is torch.Size([144]).
size mismatch for features.8.conv.3.weight: copying a param with shape torch.Size([200, 1, 3, 3]) from checkpoint, the shape in current model is torch.Size([144, 1, 5, 5]).
size mismatch for features.8.conv.4.weight: copying a param with shape torch.Size([200]) from checkpoint, the shape in current model is torch.Size([144]).
size mismatch for features.8.conv.4.bias: copying a param with shape torch.Size([200]) from checkpoint, the shape in current model is torch.Size([144]).
size mismatch for features.8.conv.4.running_mean: copying a param with shape torch.Size([200]) from checkpoint, the shape in current model is torch.Size([144]).
size mismatch for features.8.conv.4.running_var: copying a param with shape torch.Size([200]) from checkpoint, the shape in current model is torch.Size([144]).
size mismatch for features.8.conv.7.weight: copying a param with shape torch.Size([80, 200, 1, 1]) from checkpoint, the shape in current model is torch.Size([48, 144, 1, 1]).
size mismatch for features.8.conv.8.weight: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([48]).
size mismatch for features.8.conv.8.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([48]).
size mismatch for features.8.conv.8.running_mean: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([48]).
size mismatch for features.8.conv.8.running_var: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([48]).
size mismatch for features.9.conv.0.weight: copying a param with shape torch.Size([184, 80, 1, 1]) from checkpoint, the shape in current model is torch.Size([288, 48, 1, 1]).
size mismatch for features.9.conv.1.weight: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([288]).
size mismatch for features.9.conv.1.bias: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([288]).
size mismatch for features.9.conv.1.running_mean: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([288]).
size mismatch for features.9.conv.1.running_var: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([288]).
size mismatch for features.9.conv.3.weight: copying a param with shape torch.Size([184, 1, 3, 3]) from checkpoint, the shape in current model is torch.Size([288, 1, 5, 5]).
size mismatch for features.9.conv.4.weight: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([288]).
size mismatch for features.9.conv.4.bias: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([288]).
size mismatch for features.9.conv.4.running_mean: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([288]).
size mismatch for features.9.conv.4.running_var: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([288]).
size mismatch for features.9.conv.7.weight: copying a param with shape torch.Size([80, 184, 1, 1]) from checkpoint, the shape in current model is torch.Size([96, 288, 1, 1]).
size mismatch for features.9.conv.8.weight: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.9.conv.8.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.9.conv.8.running_mean: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.9.conv.8.running_var: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.10.conv.0.weight: copying a param with shape torch.Size([184, 80, 1, 1]) from checkpoint, the shape in current model is torch.Size([576, 96, 1, 1]).
size mismatch for features.10.conv.1.weight: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.10.conv.1.bias: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.10.conv.1.running_mean: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.10.conv.1.running_var: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.10.conv.3.weight: copying a param with shape torch.Size([184, 1, 3, 3]) from checkpoint, the shape in current model is torch.Size([576, 1, 5, 5]).
size mismatch for features.10.conv.4.weight: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.10.conv.4.bias: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.10.conv.4.running_mean: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.10.conv.4.running_var: copying a param with shape torch.Size([184]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.10.conv.7.weight: copying a param with shape torch.Size([80, 184, 1, 1]) from checkpoint, the shape in current model is torch.Size([96, 576, 1, 1]).
size mismatch for features.10.conv.8.weight: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.10.conv.8.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.10.conv.8.running_mean: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.10.conv.8.running_var: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.11.conv.0.weight: copying a param with shape torch.Size([480, 80, 1, 1]) from checkpoint, the shape in current model is torch.Size([576, 96, 1, 1]).
size mismatch for features.11.conv.1.weight: copying a param with shape torch.Size([480]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.11.conv.1.bias: copying a param with shape torch.Size([480]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.11.conv.1.running_mean: copying a param with shape torch.Size([480]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.11.conv.1.running_var: copying a param with shape torch.Size([480]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.11.conv.3.weight: copying a param with shape torch.Size([480, 1, 3, 3]) from checkpoint, the shape in current model is torch.Size([576, 1, 5, 5]).
size mismatch for features.11.conv.4.weight: copying a param with shape torch.Size([480]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.11.conv.4.bias: copying a param with shape torch.Size([480]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.11.conv.4.running_mean: copying a param with shape torch.Size([480]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.11.conv.4.running_var: copying a param with shape torch.Size([480]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.11.conv.5.fc.0.weight: copying a param with shape torch.Size([120, 480]) from checkpoint, the shape in current model is torch.Size([144, 576]).
size mismatch for features.11.conv.5.fc.0.bias: copying a param with shape torch.Size([120]) from checkpoint, the shape in current model is torch.Size([144]).
size mismatch for features.11.conv.5.fc.2.weight: copying a param with shape torch.Size([480, 120]) from checkpoint, the shape in current model is torch.Size([576, 144]).
size mismatch for features.11.conv.5.fc.2.bias: copying a param with shape torch.Size([480]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for features.11.conv.7.weight: copying a param with shape torch.Size([112, 480, 1, 1]) from checkpoint, the shape in current model is torch.Size([96, 576, 1, 1]).
size mismatch for features.11.conv.8.weight: copying a param with shape torch.Size([112]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.11.conv.8.bias: copying a param with shape torch.Size([112]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.11.conv.8.running_mean: copying a param with shape torch.Size([112]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for features.11.conv.8.running_var: copying a param with shape torch.Size([112]) from checkpoint, the shape in current model is torch.Size([96]).
size mismatch for conv.0.0.weight: copying a param with shape torch.Size([960, 160, 1, 1]) from checkpoint, the shape in current model is torch.Size([576, 96, 1, 1]).
size mismatch for conv.0.1.weight: copying a param with shape torch.Size([960]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for conv.0.1.bias: copying a param with shape torch.Size([960]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for conv.0.1.running_mean: copying a param with shape torch.Size([960]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for conv.0.1.running_var: copying a param with shape torch.Size([960]) from checkpoint, the shape in current model is torch.Size([576]).
size mismatch for classifier.1.weight: copying a param with shape torch.Size([1280, 960]) from checkpoint, the shape in current model is torch.Size([1280]).
Code:
net_large.load_state_dict(torch.load('pretrained/mobilenetv3-large-657e7b3d.pth'))
Error:
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".
Specifically, what optimization algorithm, learning rate schedule, and batch size did you use?
Many thanks for your work!!!
I want to use the mobilenet_v3_small_0.75 model, would you please upload the pretrained model?
Mobilenetv3模块实现部分好像少了一个pointwise convolution, 见 https://github.com/d-li14/mobilenetv3.pytorch/blob/master/mobilenetv3.py#:~:text=and%20inp%20%3D%3D%20oup-,if%20inp%20%3D%3D%20hidden_dim%3A,),-else%3A
在line94-104
这部分只适用于第一个模块,代码可以继续简化
line 18
the function view() has some problem when calculating topk=5
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces).
the instruction may solve this problem
correct_k = correct[:k].view(-1).float().sum(0)
changed to correct_k = correct[:k].float().sum()
Hi,
In the cfgs of mobilenetv3_large model, the location of the last stride 2 block seems to be different from the paper?
Am i missing anything?
Thanks
Hi. In your code, you place the activation (hard-swish), after the SE Block
self.conv = nn.Sequential(
# pw
nn.Conv2d(inp, hidden_dim, 1, 1, 0, bias=False),
nn.BatchNorm2d(hidden_dim),
h_swish() if use_hs else nn.ReLU(inplace=True),
# dw
nn.Conv2d(hidden_dim, hidden_dim, kernel_size, stride, (kernel_size - 1) // 2, groups=hidden_dim, bias=False),
nn.BatchNorm2d(hidden_dim),
# Squeeze-and-Excite
SELayer(hidden_dim) if use_se else nn.Identity(),
h_swish() if use_hs else nn.ReLU(inplace=True), ## <-- HERE!!!
# pw-linear
nn.Conv2d(hidden_dim, oup, 1, 1, 0, bias=False),
nn.BatchNorm2d(oup),
)
Is it correct, or should it be placed before the SE Block?
@d-li14 Thank you very much for your work. I was wondering if you can provide train loss curve as well? It can be in the form of training log in txt or plot like this: https://github.com/d-li14/octconv.pytorch (https://raw.githubusercontent.com/d-li14/octconv.pytorch/master/fig/ablation.png)
Btw, you may want to consider replacing conv2d + pad for future work as:
conv2d = nn.Sequential(
nn.ZeroPad([ x1,y1,x2,y2]),
nn.Conv2d( in_channel, out_channel, kernel_size, stride, padding=0, ...)
)
if you do this, and by selecting correct [ x1,y1,x2,y2], your model can be converted to tf or tf/keras or tflite model with same accuracy. tensorflow tf uses unsymmetrical padding. I have make a pytorch to tf converter for your mobilenet v3 and verified that numerical accuracy can be obtained (numerical difference of less than 1e-6)
Many uses of mobilenet are in mobile phone and are served in tflite. tiflite also allows for 8-bit quantisation
Hi,
I am running your implementation with the hyper parameters you provided using the examples/imagenet/main.py provided by PyTorch. Seems like the accuracy metrics are stuck around after epoch 20. Could you please share your training script with hyper parameter settings?
The stride here should be 2 and the next layer should be 1, refering to https://arxiv.org/pdf/1905.02244.pdf.
mobilenetv3.pytorch/mobilenetv3.py
Line 210 in 121d38b
Hi,i want to know what is the mean and std of the image when you training?
hello.
can i have your training loop?
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?
Hi @d-li14
Thank you for your work.
When I read the original MobileNetV3 paper and compared with your code, I noticed a discrepancy in the code. Specifically, in this line [https://github.com/d-li14/mobilenetv3.pytorch/blob/master/mobilenetv3.py#L211], the code is: [5, 672, 160, 1, 1, 2].
However, the corresponding line in table 1 of the original paper is: 7
2 × 160, bneck, 5x5 960-160-checkmark-HS-1 (row 6 counted from the bottom)
Can you help to confirm that and re-adjust your code accordingly?
Thanks,
P
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?
Thank you for your code! It is really very helpful for our project.
But I have a little question. When testing the Madds of mobilenetv3_large with Op_counter, we got 239M instead of 217M reported in the repo (Searching for MobileNetV3). Are there some differences in structures between the mobilenetv3 in this repo and the original one? Or it is due to the way to calculate Madds?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.