All Projects → ricky40403 → Dsq

ricky40403 / Dsq

pytorch implementation of "Differentiable Soft Quantization: Bridging Full-Precision and Low-Bit Neural Networks"

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Dsq

Deephash Papers
Must-read papers on deep learning to hash (DeepHash)
Stars: ✭ 302 (+331.43%)
Mutual labels:  quantization
Paddleclas
A treasure chest for image classification powered by PaddlePaddle
Stars: ✭ 625 (+792.86%)
Mutual labels:  quantization
Sai
SDK for TEE AI Stick (includes model training script, inference library, examples)
Stars: ✭ 28 (-60%)
Mutual labels:  quantization
Libimagequant
Palette quantization library that powers pngquant and other PNG optimizers
Stars: ✭ 344 (+391.43%)
Mutual labels:  quantization
Aimet
AIMET is a library that provides advanced quantization and compression techniques for trained neural network models.
Stars: ✭ 453 (+547.14%)
Mutual labels:  quantization
Paddleslim
PaddleSlim is an open-source library for deep model compression and architecture search.
Stars: ✭ 677 (+867.14%)
Mutual labels:  quantization
Qkeras
QKeras: a quantization deep learning library for Tensorflow Keras
Stars: ✭ 254 (+262.86%)
Mutual labels:  quantization
Jacinto Ai Devkit
Training & Quantization of embedded friendly Deep Learning / Machine Learning / Computer Vision models
Stars: ✭ 49 (-30%)
Mutual labels:  quantization
Awesome Emdl
Embedded and mobile deep learning research resources
Stars: ✭ 554 (+691.43%)
Mutual labels:  quantization
Training extensions
Trainable models and NN optimization tools
Stars: ✭ 857 (+1124.29%)
Mutual labels:  quantization
Brevitas
Brevitas: quantization-aware training in PyTorch
Stars: ✭ 343 (+390%)
Mutual labels:  quantization
Deephash
An Open-Source Package for Deep Learning to Hash (DeepHash)
Stars: ✭ 417 (+495.71%)
Mutual labels:  quantization
Awesome Automl And Lightweight Models
A list of high-quality (newest) AutoML works and lightweight models including 1.) Neural Architecture Search, 2.) Lightweight Structures, 3.) Model Compression, Quantization and Acceleration, 4.) Hyperparameter Optimization, 5.) Automated Feature Engineering.
Stars: ✭ 691 (+887.14%)
Mutual labels:  quantization
Distiller
Neural Network Distiller by Intel AI Lab: a Python package for neural network compression research. https://intellabs.github.io/distiller
Stars: ✭ 3,760 (+5271.43%)
Mutual labels:  quantization
Model Optimization
A toolkit to optimize ML models for deployment for Keras and TensorFlow, including quantization and pruning.
Stars: ✭ 992 (+1317.14%)
Mutual labels:  quantization
Finn
Dataflow compiler for QNN inference on FPGAs
Stars: ✭ 284 (+305.71%)
Mutual labels:  quantization
Pinto model zoo
A repository that shares tuning results of trained models generated by TensorFlow / Keras. Post-training quantization (Weight Quantization, Integer Quantization, Full Integer Quantization, Float16 Quantization), Quantization-aware training. TensorFlow Lite. OpenVINO. CoreML. TensorFlow.js. TF-TRT. MediaPipe. ONNX. [.tflite,.h5,.pb,saved_model,tfjs,tftrt,mlmodel,.xml/.bin, .onnx]
Stars: ✭ 634 (+805.71%)
Mutual labels:  quantization
Ntagger
reference pytorch code for named entity tagging
Stars: ✭ 58 (-17.14%)
Mutual labels:  quantization
Quantization.mxnet
Simulate quantization and quantization aware training for MXNet-Gluon models.
Stars: ✭ 42 (-40%)
Mutual labels:  quantization
Libimagequant Rust
libimagequant (pngquant) bindings for the Rust language
Stars: ✭ 17 (-75.71%)
Mutual labels:  quantization

DSQ

pytorch unofficial implementation of "Differentiable Soft Quantization: Bridging Full-Precision and Low-Bit Neural Networks"


The Origin Paper : https://arxiv.org/abs/1908.05033


This repository follow the Algorithm 1 in the paper.

This repository uses the max value of int32 as the initial value.
It should not affect the value range (because the parameter of the deep model should not too large), and most of the edge device range is up to int32.


Training

Training with quantization. Scrip modified from https://github.com/pytorch/examples/tree/master/imagenet

Now support uniform/DSQ quantization
adding argments
-q : quantization type, default is None
--quantize_input : quantize input or not
--quan_bit : quantization bit num
--log_path : tensorboard log path to write, default folder is ./log.

Examples
Training DSQ with 8 bit (no quantiza input)

python train.py -a resnet18  -q DSQ --quan_bit 8 {Path to data}

Training DSQ with 8 bit ( quantiza input)

python train.py -a resnet18  -q DSQ --quan_bit 8 --quantize_input {Path to data}

Evaluating (directly use evaluation and resume from model_best.pth.tar)

python train.py -a resnet18 -q DSQ --quan_bit 8 --quantize_input --resume {path to model_best.pth.tar} -- evaluate {Path to data}

Experiments

The results is base on fake-quantization.(only quantized convolution). As the mentioned in the paper, not to quantize the final Linear Layer.

model QuanType W/A bit top1 top5
resnet18 UniformQuan 4/32 69.486 89.004
DSQ 4/32 69.328 88.872
UniformQuan 4/4 69.306 88.780
DSQ 4/4 69.542 88.884

learned alpha for 4 bit DSQ (quantize weight and input)

layer weight activation
layer1.0.conv1 0.4832 0.5661
layer1.0.conv2 0.3730 0.2953
layer1.1.conv1 0.4405 0.2975
layer1.1.conv2 0.3427 0.1959
layer2.0.conv1 0.3966 0.1653
layer2.0.conv2 0.4140 0.2014
layer2.downsample 0.3275 0.1779
layer2.1.conv1 0.4303 0.1675
layer2.1.conv2 0.4207 0.1570
layer3.0.conv1 0.4590 0.2774
layer3.0.conv2 0.4838 0.2569
layer3.downsample 0.2305 0.1073
layer3.1.conv1 0.4523 0.1775
layer3.1.conv2 0.4382 0.1792

Resutls:

As the table2 in the paper, it indeed show that

Second, different layers show different sensitivity to the quantization.  
For example, the downsampling convolution layers can be quantized much (a small α),
while some layers such as layer3.0.conv2 are not suitable for  quantization (a large α).  

Issue:

It seems that α of weights is bigger than that of activations.
Maybe the un-quantize batchnorm restricts the activation and cause the difference to the paper. (or someone can tell why)

Update Note

20191218: Update uniform quantization results. It seems that the sgn function still need STE backward or the loss will becomes Nan.
20191231: Update Experiments.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].