@@ -74,27 +74,6 @@ python -m torch.distributed.launch --nproc_per_node=8 --use_env train.py\
74
74
```
75
75
76
76
## Quantized
77
- ### INT8 models
78
- We add INT8 quantized models to follow the quantization support added in PyTorch 1.3.
79
-
80
- Obtaining a pre-trained quantized model can be obtained with a few lines of code:
81
- ```
82
- model = torchvision.models.quantization.mobilenet_v2(pretrained=True, quantize=True)
83
- model.eval()
84
- # run the model with quantized inputs and weights
85
- out = model(torch.rand(1, 3, 224, 224))
86
- ```
87
- We provide pre-trained quantized weights for the following models:
88
-
89
- | Model | Acc@1 | Acc@5 |
90
- | :-----------------:| :------:| :------:|
91
- | MobileNet V2 | 71.658 | 90.150 |
92
- | ShuffleNet V2: | 68.360 | 87.582 |
93
- | ResNet 18 | 69.494 | 88.882 |
94
- | ResNet 50 | 75.920 | 92.814 |
95
- | ResNext 101 32x8d | 78.986 | 94.480 |
96
- | Inception V3 | 77.176 | 93.354 |
97
- | GoogleNet | 69.826 | 89.404 |
98
77
99
78
### Parameters used for generating quantized models:
100
79
@@ -106,6 +85,10 @@ For all post training quantized models (All quantized models except mobilenet-v2
106
85
4 . eval_batch_size: 128
107
86
5 . backend: 'fbgemm'
108
87
88
+ ```
89
+ python train_quantization.py --device='cpu' --post-training-quantize --backend='fbgemm' --model='<model_name>'
90
+ ```
91
+
109
92
For Mobilenet-v2, the model was trained with quantization aware training, the settings used are:
110
93
1 . num_workers: 16
111
94
2 . batch_size: 32
@@ -119,14 +102,17 @@ For Mobilenet-v2, the model was trained with quantization aware training, the se
119
102
10 . lr_step_size:30
120
103
11 . lr_gamma: 0.1
121
104
105
+ ```
106
+ python -m torch.distributed.launch --nproc_per_node=8 --use_env train_quantization.py --model='mobilenetv2'
107
+ ```
108
+
122
109
Training converges at about 10 epochs.
123
110
124
111
For post training quant, device is set to CPU. For training, the device is set to CUDA
125
112
126
113
### Command to evaluate quantized models using the pre-trained weights:
127
- For all quantized models:
114
+
128
115
```
129
- python references/classification/train_quantization.py --data-path='imagenet_full_size/' \
130
- --device='cpu' --test-only --backend='fbgemm' --model='<model_name>'
116
+ python train_quantization.py --device='cpu' --test-only --backend='fbgemm' --model='<model_name>'
131
117
```
132
118
0 commit comments