Existing AdderNet quantization techniques propose to
use only one shared scale to quantize both the weights and activations simultaneously.
We propos a new quantization algorithm by redistributing the weights and the activations. Specifically, the pre-trained
full-precision weights in different kernels are clustered into different groups, then
the intra-group sharing and inter-group independent scales can be adopted. To
further compensate the accuracy drop caused by the distribution difference, we
then develop a lossless range clamp scheme for weights and a simple yet effective
outliers clamp strategy for activations. Thus, the functionality of full-precision
weights and the representation ability of full-precision activations can be fully
preserved.
Paper: Redistribution of Weights and Activations for AdderNet Quantization. Ying Nie, Kai Han1, Haikang Diao, Chuanjian Liu, Enhua Wu, Yunhe Wang
The illustration of the proposed quantization method for AdderNet (symmetric 4-bit as an
example). The pre-trained full-precision weights are clustered into different groups. Then the clamp
scheme for weights and activations are explored respectively to make efficient use of the precious
bits and eliminate the negative impact of outliers.
Note that you can run the scripts based on the dataset mentioned in original paper or widely used in relevant domain/network architecture. In the following sections, we will introduce how to run the scripts using the related dataset below.
Dataset used: CIFAR-10
├─cifar-10-batches-bin
│
└─cifar-10-verify-bin
AdderQuant
.
├── README.md # Readme file
├── adder_quant.py # AdderNet with Quantization Algorithm
├── eval.py # Evaluation
├── requirements.txt # requirements
└── res20_adder.py # Resnet with Addernet Conv
After installing MindSpore via the official website, you can start evaluation as follows:
# infer example
# python
GPU: python eval.py --checkpoint_file_path path/to/ckpt --train_dataset_path path/to/cifar-10-batches-bin --eval_dataset_path path/to/cifar-10-verify-bin
checkpoint can be downloaded at https://download.mindspore.cn/model_zoo/research/cv/AdderQuant/
Quantization results of AdderNets(ResNet-20 with 90.44full-precision) on CIFAR-10:
Bits | PTQ(%) |
---|---|
8 | 91.36 |
6 | 91.21 |
5 | 90.86 |
4 | 90.27 |
Please check the official homepage.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。