# MobilenetV3 **Repository Path**: yangdashi/MobilenetV3 ## Basic Information - **Project Name**: MobilenetV3 - **Description**: 1、其特点:将最后一层的平均池化层前移,并且后面用1*1的卷积核来进行代替,并且是有h_swish激活函数,并且添加了Dropout夹在最后一层1*1的卷积层前。 2、V3是融合了三种模型的思想:mobilenetv1的深度可分离卷积(depthwise separable convolutions)mobilenetv2的具有线性瓶颈的逆残差结构(the inverted residual with linear bottleneck)和MnasNet的Squeeze and excitation结构的轻量级注意模型。 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-10-29 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 1、其特点:将最后一层的平均池化层前移,并且后面用1*1的卷积核来进行代替,并且是有h_swish激活函数,并且添加了Dropout夹在最后一层1*1的卷积层前。 2、V3是融合了三种模型的思想:mobilenetv1的深度可分离卷积(depthwise separable convolutions)mobilenetv2的具有线性瓶颈的逆残差结构(the inverted residual with linear bottleneck)和MnasNet的Squeeze and excitation结构的轻量级注意模型。 参考博客:[轻量级网络——MobileNetV3终于来了](https://blog.csdn.net/DL_wly/article/details/90168883) # Implementing Searching for MobileNetV3 paper using Pytorch - The current model is a very early model. I will modify it as a general model as soon as possible. ## Paper - [Searching for MobileNetV3 paper](https://arxiv.org/abs/1905.02244) - Author: Andrew Howard(Google Research), Mark Sandler(Google Research, Grace Chu(Google Research), Liang-Chieh Chen(Google Research), Bo Chen(Google Research), Mingxing Tan(Google Brain), Weijun Wang(Google Research), Yukun Zhu(Google Research), Ruoming Pang(Google Brain), Vijay Vasudevan(Google Brain), Quoc V. Le(Google Brain), Hartwig Adam(Google Research) ## Todo - Experimental need for ImageNet dataset. - Code refactoring ## MobileNetV3 Block ![캡처](https://images.gitee.com/uploads/images/2019/1029/120206_d3399724_1184321.png) ## Experiments - For CIFAR-100 data, I experimented with resize (224, 224).
| Datasets | Model | acc1 | acc5 | Epoch | Parameters | :---: | :---: | :---: | :---: | :---: | :---: | CIFAR-100 | MobileNetV3(LARGE) | 70.44% | 91.34% | 80 | 3.99M CIFAR-100 | MobileNetV3(SMALL) | 67.04% | 89.41% | 55 | 1.7M IMAGENET | MobileNetV3(LARGE) WORK IN PROCESS | | | | 5.15M IMAGENET | MobileNetV3(SMALL) WORK IN PROCESS | | | | 2.94M ## Usage ### Train ``` python main.py ``` - If you want to change hyper-parameters, you can check "python main.py --help" Options: - `--dataset-mode` (str) - which dataset you use, (example: CIFAR10, CIFAR100), (default: CIFAR100). - `--epochs` (int) - number of epochs, (default: 100). - `--batch-size` (int) - batch size, (default: 128). - `--learning-rate` (float) - learning rate, (default: 1e-1). - `--dropout` (float) - dropout rate, (default: 0.3). - `--model-mode` (str) - which network you use, (example: LARGE, SMALL), (default: LARGE). - `--load-pretrained` (bool) - (default: False). - `--evaluate` (bool) - Used when testing. (default: False). - `--multiplier` (float) - (default: 1.0). ### Test ``` python main.py --evaluate True ``` - Put the saved model file in the checkpoint folder and saved graph file in the saved_graph folder and type "python main.py --evaluate True". - If you want to change hyper-parameters, you can check "python test.py --help" Options: - `--dataset-mode` (str) - which dataset you use, (example: CIFAR10, CIFAR100), (default: CIFAR100). - `--epochs` (int) - number of epochs, (default: 100). - `--batch-size` (int) - batch size, (default: 128). - `--learning-rate` (float) - learning rate, (default: 1e-1). - `--dropout` (float) - dropout rate, (default: 0.3). - `--model-mode` (str) - which network you use, (example: LARGE, SMALL), (default: LARGE). - `--load-pretrained` (bool) - (default: False). - `--evaluate` (bool) - Used when testing. (default: False). - `--multiplier` (float) - (default: 1.0). ### Number of Parameters ```python import torch from model import MobileNetV3 def get_model_parameters(model): total_parameters = 0 for layer in list(model.parameters()): layer_parameter = 1 for l in list(layer.size()): layer_parameter *= l total_parameters += layer_parameter return total_parameters tmp = torch.randn((128, 3, 224, 224)) model = MobileNetV3(model_mode="LARGE", multiplier=1.0) print("Number of model parameters: ", get_model_parameters(model)) ``` ## Requirements - torch==1.0.1