GithubHelp home page GithubHelp logo

torch_quant's Introduction

Implentation of Uniform/Non-Uniform Quantization of Weight Normalization based model

Still Under Construction.

Todo

  • kmeans quantization
  • finetuning the quantized model for cifar
  • freeze the weights and training the scale factor after quantization
  • finetuning the quantized model for imagenet
  • expansion and compression of the weights
  • depth-wise convolution quantization

Usage

Test resnet

python main_imgnet_training.py ~/workspace/dataset/torch_imagenet/CLS-LOC/ -a resnet --pretrained  --resume ./R-50-GN-WS.pth.tar -e --dist-url 'tcp://127.0.0.1:8888' --dist-backend 'nccl' --multiprocessing-distributed --world-size 1 --rank 0

Train Activation quantized model for cifar10

python train_cifar.py -a alexnet --epochs 164 --schedule 81 122 --gamma 0.1 --lr 0.01 --a_quant --a_bit 8 --checkpoint checkpoints/cifar10/alexnet_act8   

Test with cifar10

 python train_cifar.py -a alexnet --epochs 164 --schedule 81 122 --gamma 0.1 --lr 0.01 --checkpoint checkpoints/cifar10/alexnet_dorefa --resume checkpoints/cifar10/alexnet/model_best.pth.tar

Save the Standard Weight based model as normal model

python save_WN_as_norm.py

Quantize the weight

kmeans quantization:

python weightquant.py --input_ckpt ./R-50-GN-WS-flod.pth.tar --quant_method kmeans --output_ckpt ./R-50-GN-WS-q --weight_bits 4 --n_sample 10000

linear quantization:

python weightquant.py --input_ckpt ./R-50-GN-WS-flod.pth.tar --quant_method linear --output_ckpt ./R-50-GN-WS-q --weight_bits 4

Citaiton:

* Weight Standardlization

* AlexNet

* VGG (Imported from pytorch-cifar)

* ResNet

* Pre-act-ResNet

* ResNeXt (Imported from ResNeXt.pytorch)

* Wide Residual Networks (Imported from WideResNet-pytorch)

* DenseNet

torch_quant's People

Contributors

swingxu avatar

Stargazers

 avatar Hao-Lun Sun avatar  avatar Ferdinand Mom avatar Peng He avatar Yikai Wang avatar

Watchers

James Cloos avatar paper2code - bot avatar

Forkers

ameenali

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.