Home

Awesome

Any-Precision Deep Neural Network

Official code and models in PyTorch for the paper Any-Precision Deep Neural Networks.

Run

Environment

Train

Resnet-20 Models on CIFAR10

Run the script below and dataset will download automatically.

./train_cifar10.sh
SVHN Models on SVHN

Run the script below and dataset will download automatically.

./train_svhn.sh
Resnet-50 Models on ImageNet

Before running the script below, one needs to manually download ImageNet and save it properly according to data_paths in dataset/data.py.

./train_imagenet.sh

Test

To test a trained model, simply run the corresponding training script for one epoch with pretrained model loaded and without the training part.

Trained Models

Due to the following listed training hyperparameter changes, numbers below may be different from those in the paper.

Resnet-20 Models on CIFAR10
Models1 bit2 bit4 bit8 bitFP32
Resnet-2091.5093.2693.6293.4293.58
Resnet-20-Any (hard<sup>1</sup>)91.4893.7493.8793.9293.71
Resnet-20-Any (soft<sup>2</sup>)91.1893.5193.2193.1393.63
Resnet-20-Any (recursive<sup>3</sup>)91.8993.9093.8693.7594.11

1: Softmax Cross Entropy Loss
2: Softmax Cross Entropy Loss with FP32 prediction as supervision
3: Softmax Cross Entropy Loss with higher-precision model as supervision for lower-precision model

SVHN Models on SVHN
Models1 bit2 bit4 bit8 bitFP32
SVHN90.9496.4597.0497.0497.10
SVHN-Any (hard)88.9895.5496.7196.7296.60
SVHN-Any (soft)88.4994.6296.1396.2096.17
SVHN-Any (recursive)88.2194.9496.1996.2296.29
Resnet-50 Models on ImageNet
Models1 bit2 bit4 bit8 bitFP32
Resnet-5057.83<sup>4</sup>68.74<sup>4</sup>74.12<sup>5</sup>74.96<sup>5</sup>75.95<sup>5</sup>
Resnet-50-Any (recursive)58.7771.6673.8474.0774.63

4: Weight decay 1e-5
5: Weight decay 1e-4

Citation

If you find this repository helpful, please consider citing our paper:

@article{yu2019any,
  title={Any-Precision Deep Neural Networks},
  author={Yu, Haichao and Li, Haoxiang and Shi, Honghui and Huang, Thomas S and Hua, Gang},
  journal={arXiv preprint arXiv:1911.07346},
  year={2019}
}

Contact

Please feel free to contact Haichao Yu at haichao.yu@outlook.com for any issue.