README.md 3.82 KB
Newer Older
sugon_cxj's avatar
sugon_cxj committed
1
# mobilenet_prune
chenxj's avatar
chenxj committed
2
## 论文
dcuai's avatar
dcuai committed
3
4
5
* EfficientNet https://arxiv.org/pdf/1905.11946.pdf 
* mobilenetv2 https://arxiv.org/pdf/1801.04381.pdf 
* mobilenetv3 https://arxiv.org/pdf/1905.02244.pdf 
sugon_cxj's avatar
sugon_cxj committed
6
## 模型结构
chenxj's avatar
chenxj committed
7
8
mobilenetv2:

chenxj's avatar
chenxj committed
9
![image](https://developer.hpccube.com/codes/modelzoo/mobilenet_prune/-/raw/main/mobilenetv2.png)
chenxj's avatar
chenxj committed
10
11

详细模型结构见官方论文:
dcuai's avatar
dcuai committed
12
13
14
* EfficientNet https://arxiv.org/pdf/1905.11946.pdf 
* mobilenetv2 https://arxiv.org/pdf/1801.04381.pdf 
* mobilenetv3 https://arxiv.org/pdf/1905.02244.pdf 
chenxj's avatar
chenxj committed
15
## 算法原理
dcuai's avatar
dcuai committed
16

sugon_cxj's avatar
sugon_cxj committed
17
## 数据集
dcuai's avatar
dcuai committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
`CIFAR-10`

- [https://www.cs.toronto.edu/~kriz/cifar.html](https://www.cs.toronto.edu/~kriz/cifar.html)

训练数据目录结构如下,用于正常训练的完整数据集请按此目录结构进行制备:
```
├── cifar-10-batches-py
│   ├── batches.meta
│   ├── data_batch_1
│   ├── data_batch_2
│   ├── data_batch_3
│   ├── data_batch_4
│   ├── data_batch_5
│   ├── readme.html
│   └── test_batch
```
**tips:本模型也会自动下载数据集
chenxj's avatar
chenxj committed
35
## 环境配置
chenxj's avatar
chenxj committed
36
[光源](https://sourcefind.cn/#/main-page)可拉取剪枝及微调的docker镜像,在[光合开发者社区](https://cancon.hpccube.com:65024/4/main/)可下载torch安装包。mobilenet_prune推荐的镜像如下:
sugon_cxj's avatar
sugon_cxj committed
37
```
chenxj's avatar
chenxj committed
38
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.13.1-centos7.6-dtk-23.04.1-py37-latest
chenxj's avatar
chenxj committed
39
40
docker run -d -t --privileged --device=/dev/kfd --device=/dev/dri/ --network=host --group-add video --name prune-test image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.13.1-centos7.6-dtk-23.04.1-py37-latest
docker exec -it prune-test bash
sugon_cxj's avatar
sugon_cxj committed
41
```
chenxj's avatar
chenxj committed
42
安装依赖
sugon_cxj's avatar
sugon_cxj committed
43
44
45
46
```
cd mobilenet_prune
pip3 install -r requirements.txt
```
dcuai's avatar
dcuai committed
47
48
## 训练
### 剪枝
sugon_cxj's avatar
sugon_cxj committed
49
50
51
52
53
54
55
56
57
58
59
60
efficientnet
```
python3 main.py --mode prune --model efficientnet --batch-size 128 --restore ./checkpoints/efficientnet.pt --dataset cifar10  --method l1 --speed-up 2.11 --global-pruning
```
mobilenetv2
```
python3 main.py --mode prune --model mobilenetv2 --batch-size 128 --restore ./checkpoints/mobilenetv2.pt --dataset cifar10  --method l1 --speed-up 2.11 --global-pruning
```
mobilenetv3
```
python3 main.py --mode prune --model mobilenetv3 --batch-size 128 --restore ./checkpoints/mobilenetv3.pt --dataset cifar10  --method l1 --speed-up 2.11 --global-pruning
```
dcuai's avatar
dcuai committed
61
### 测试
sugon_cxj's avatar
sugon_cxj committed
62
63
64
65
66
67
68
69
70
71
72
73
efficientnet
```
python3 main.py --mode test --model efficientnet --batch-size 128 --restore ./run/cifar10/prune/cifar10-global-l1-efficientnet/cifar10_efficientnet_l1.pt --dataset cifar10  --method l1 --speed-up 2.11 --global-pruning
```
mobilenetv2
```
python3 main.py --mode test --model mobilenetv2 --batch-size 128 --restore ./run/cifar10/prune/cifar10-global-l1-mobilenetv2/cifar10_mobilenetv2_l1.pt --dataset cifar10  --method l1 --speed-up 2.11 --global-pruning
```
mobilenetv3
```
python3 main.py --mode test --model mobilenetv3 --batch-size 128 --restore ./run/cifar10/prune/cifar10-global-l1-mobilenetv3/cifar10_mobilenetv3_l1.pt --dataset cifar10  --method l1 --speed-up 2.11 --global-pruning
```
chenxj's avatar
chenxj committed
74
## result
dcuai's avatar
dcuai committed
75

chenxj's avatar
chenxj committed
76
### 精度
sugon_cxj's avatar
sugon_cxj committed
77
method l1
chenxj's avatar
chenxj committed
78
79
80
81
82
| model | Base Acc | Pruned Acc | 
| :------: | :------: |:------: |
| efficientnet | 0.9300 | 0.9248 | 
| mobilenetv2 | 0.9222 | 0.9205 | 
| mobilenetv3 | 0.9034 | 0.8963 | 
sugon_cxj's avatar
sugon_cxj committed
83
84

method lamp
chenxj's avatar
chenxj committed
85
86
87
88
89
| model | Base Acc | Pruned Acc | 
| :------: | :------: |:------: |
| efficientnet | 0.9300 | 0.9256 | 
| mobilenetv2 | 0.9222 | 0.9225 | 
| mobilenetv3 | 0.9034 | 0.9044 | 
sugon_cxj's avatar
sugon_cxj committed
90
91

method group_norm
chenxj's avatar
chenxj committed
92
93
94
95
96
| model | Base Acc | Pruned Acc | 
| :------: | :------: |:------: |
| efficientnet | 0.9300 | 0.8977 | 
| mobilenetv2 | 0.9222 | 0.8953 | 
| mobilenetv3 | 0.9034 | 0.8852 | 
sugon_cxj's avatar
sugon_cxj committed
97

chenxj's avatar
chenxj committed
98
99
100
101
102
## 应用场景
### 算法类别
图像分类
### 热点应用行业
交通,金融,医疗,教育,家居
sugon_cxj's avatar
sugon_cxj committed
103
104
## 源码仓库及问题反馈
https://developer.hpccube.com/codes/modelzoo/mobilenet_prune
chenxj's avatar
chenxj committed
105
## 参考资料
sugon_cxj's avatar
sugon_cxj committed
106
* [Torch-Pruning](https://github.com/VainF/Torch-Pruning)
sugon_cxj's avatar
sugon_cxj committed
107