All Projects → Mxbonn → Inq Pytorch

Mxbonn / Inq Pytorch

A PyTorch implementation of "Incremental Network Quantization: Towards Lossless CNNs with Low-Precision Weights"

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Inq Pytorch

Model Optimization
A toolkit to optimize ML models for deployment for Keras and TensorFlow, including quantization and pruning.
Stars: ✭ 992 (+574.83%)
Mutual labels:  quantization
Frostnet
FrostNet: Towards Quantization-Aware Network Architecture Search
Stars: ✭ 85 (-42.18%)
Mutual labels:  quantization
Pretrained Language Model
Pretrained language model and its related optimization techniques developed by Huawei Noah's Ark Lab.
Stars: ✭ 2,033 (+1282.99%)
Mutual labels:  quantization
Jacinto Ai Devkit
Training & Quantization of embedded friendly Deep Learning / Machine Learning / Computer Vision models
Stars: ✭ 49 (-66.67%)
Mutual labels:  quantization
Micronet
micronet, a model compression and deploy lib. compression: 1、quantization: quantization-aware-training(QAT), High-Bit(>2b)(DoReFa/Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference)、Low-Bit(≤2b)/Ternary and Binary(TWN/BNN/XNOR-Net); post-training-quantization(PTQ), 8-bit(tensorrt); 2、 pruning: normal、regular and group convolutional channel pruning; 3、 group convolution structure; 4、batch-normalization fuse for quantization. deploy: tensorrt, fp32/fp16/int8(ptq-calibration)、op-adapt(upsample)、dynamic_shape
Stars: ✭ 1,232 (+738.1%)
Mutual labels:  quantization
Hawq
Quantization library for PyTorch. Support low-precision and mixed-precision quantization, with hardware implementation through TVM.
Stars: ✭ 108 (-26.53%)
Mutual labels:  quantization
Training extensions
Trainable models and NN optimization tools
Stars: ✭ 857 (+482.99%)
Mutual labels:  quantization
Ctranslate2
Fast inference engine for OpenNMT models
Stars: ✭ 140 (-4.76%)
Mutual labels:  quantization
Pyepr
Powerful, automated analysis and design of quantum microwave chips & devices [Energy-Participation Ratio and more]
Stars: ✭ 81 (-44.9%)
Mutual labels:  quantization
Dfq
PyTorch implementation of Data Free Quantization Through Weight Equalization and Bias Correction.
Stars: ✭ 125 (-14.97%)
Mutual labels:  quantization
Ntagger
reference pytorch code for named entity tagging
Stars: ✭ 58 (-60.54%)
Mutual labels:  quantization
Vectorsinsearch
Dice.com repo to accompany the dice.com 'Vectors in Search' talk by Simon Hughes, from the Activate 2018 search conference, and the 'Searching with Vectors' talk from Haystack 2019 (US). Builds upon my conceptual search and semantic search work from 2015
Stars: ✭ 71 (-51.7%)
Mutual labels:  quantization
Tf2
An Open Source Deep Learning Inference Engine Based on FPGA
Stars: ✭ 113 (-23.13%)
Mutual labels:  quantization
Quantization.mxnet
Simulate quantization and quantization aware training for MXNet-Gluon models.
Stars: ✭ 42 (-71.43%)
Mutual labels:  quantization
Graffitist
Graph Transforms to Quantize and Retrain Deep Neural Nets in TensorFlow
Stars: ✭ 135 (-8.16%)
Mutual labels:  quantization
Sai
SDK for TEE AI Stick (includes model training script, inference library, examples)
Stars: ✭ 28 (-80.95%)
Mutual labels:  quantization
Trained Ternary Quantization
Reducing the size of convolutional neural networks
Stars: ✭ 90 (-38.78%)
Mutual labels:  quantization
Cnn Quantization
Quantization of Convolutional Neural networks.
Stars: ✭ 141 (-4.08%)
Mutual labels:  quantization
Awesome Edge Machine Learning
A curated list of awesome edge machine learning resources, including research papers, inference engines, challenges, books, meetups and others.
Stars: ✭ 139 (-5.44%)
Mutual labels:  quantization
Model Quantization
Collections of model quantization algorithms
Stars: ✭ 118 (-19.73%)
Mutual labels:  quantization

Incremental Network Quantization

A PyTorch implementation of "Incremental Network Quantization: Towards Lossless CNNs with Low-Precision Weights"

@inproceedings{zhou2017,
title={Incremental Network Quantization: Towards Lossless CNNs with Low-Precision Weights},
author={Aojun Zhou, Anbang Yao, Yiwen Guo, Lin Xu, Yurong Chen},
booktitle={International Conference on Learning Representations,ICLR2017},
year={2017},
}

[Paper]

Official Caffe implementation is available [here] (Code in this repo is based on the paper and not on the official Caffe implementation)


Installation

The code is implemented in Python 3.7 and PyTorch 1.1

pip install -e .

Usage

inq.SGD(...) implements SGD that only updates weights according to the weight partitioning scheme of INQ.

inq.INQScheduler(...) handles the the weight partitioning and group-wise quantization stages of the incremental network quantization procedure.

reset_lr_scheduler(...) resets the learning rate scheduler.

Examples

The INQ training procedure looks like the following:

optimizer = inq.SGD(...)
scheduler = torch.optim.lr_scheduler.StepLR(optimizer, ...)
inq_scheduler = inq.INQScheduler(optimizer, [0.5, 0.75, 0.82, 1.0], strategy="pruning")
for inq_step in range(3): # Iteration for accumulated quantized weights of 50% 75% and 82% 
    inq.reset_lr_scheduler(scheduler)
    inq_scheduler.step()
    for epoch in range(5):
        scheduler.step()
        train(...)
inq_scheduler.step() # quantize all weights, further training is useless
validate(...)

examples/imagenet_quantized.py is a modified version of the official PyTorch imagenet example. Using this example you can quantize a pretrained model on imagenet. Compare the file to the original example to see the differences.

Results

Results using this code differ slightly from the results reported in the paper.

Network Strategy Bit-width Top-1 Accuracy Top-5 Accuracy
resnet18 ref 32 69.758% 89.078%
resnet18 pruning 5 69.64% 89.07%
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].