Pytorch implementation of "Learnable Lookup Table for Neural Network Quantization", CVPR 2022
- PyTorch
- TorchVision
- numpy
python train.py --arch resnet20 --epochs 200 --batch_size 128 --learning_rate 0.01 --weight_decay 1e-4 --w_bits 4 --a_bits 4
python test.py --arch resnet20 --batch_size 128 --w_bits 4 --a_bits 4
- PyTorch == 1.1.0
- numpy
- skimage
- imageio
- cv2
1.1 Download DIV2K training data (800 training + 100 validtion images) from DIV2K dataset or SNU_CVLab.
1.2 Specify '--dir_data' based on the HR and LR images path. In option.py, '--ext' is set as 'sep_reset', which first convert .png to .npy. If all the training images (.png) are converted to .npy files, then set '--ext sep' to skip converting files.
For more informaiton, please refer to EDSR(PyTorch).
2.1 Download pre-trained full-precision model (e.g., EDSR) to 'model/EDSR'.
python main.py --model EDSR --scale 4 --w_bits 4 --a_bits 4 --save EDSR_w4a4 --pre_train model/EDSR/EDSR_x4.pth --patch_size 48 --batch_size 12
Download benchmark datasets (e.g., Set5, Set14 and other test sets) and prepare HR/LR images in testsets/benchmark
following the example of testsets/benchmark/Set5
.
python main.py --dir_data testsets --data_test Set5 --model EDSR --scale 4 --w_bits 4 --a_bits 4 --pre_train experiment/EDSR_w4a4/model/model_40.pt --test_only --save_results
To be updated
@InProceedings{Wang2022Learnable,
author = {Wang, Longguang and Dong, Xiaoyu and Wang, Yingqian and Liu, Li and An, Wei and Guo, Yulan},
title = {Learnable Lookup Table for Neural Network Quantization},
booktitle = {CVPR},
year = {2022},
pages = {12423--12433},
}
Part of the code is borrowed from APot. We thank the authors for sharing the codes.