LQ-Nets: Learned Quantization for Highly Accurate and Compact Deep Neural Networks

Dongqing Zhang, Jiaolong Yang, Dongqiangzi Ye, Gang Hua

Abstract

Although weight and activation quantization is an effective approach for Deep Neural Network (DNN) compression and has a lot of potentials to increase inference speed leveraging bit-operations, there is still a noticeable gap in terms of prediction accuracy between the quantized model and the full-precision model. To address this gap, we propose to jointly train a quantized, bit-operation-compatible DNN and its associated quantizers, as opposed to using fixed, handcrafted quantization schemes such as uniform or logarithmic quantization. Our method for learning the quantizers applies to both network weights and activations with arbitrary-bit precision, and our quantizers are easy to train. The comprehensive experiments on CIFAR-10 and ImageNet datasets show that our method works consistently well for various network structures such as AlexNet, VGG-Net, GoogLeNet, ResNet, and DenseNet, surpassing previous quantization methods in terms of accuracy by an appreciable margin.

Introduction

Deep learning has revolutionized computer vision, but its "heavyweight" nature—requiring massive memory and high computational power—makes it difficult to deploy on resource-constrained devices like smartphones or IoT hardware.

Quantization is a popular solution: it replaces 32-bit floating-point numbers with low-precision integers (e.g., 1 or 2 bits). While this drastically reduces model size and enables fast bitwise operations (XNOR and Popcount), it usually comes at a steep cost in accuracy. Most existing methods use "handcrafted" quantizers—like uniform or logarithmic schemes—that don't account for the unique data distributions found in different layers of a network. This "one-size-fits-all" approach leaves a significant performance gap compared to full-precision models.

The Learnable Quantizer

The core innovation of LQ-Nets is the Learnable Quantizer. Instead of forcing weights and activations into a pre-defined grid, the authors propose learning a floating-point basis vector ($v$) for each layer. This adaptivity is crucial because, as shown in the distributions below, the statistical properties of weights and activations vary significantly across different layers of a network.

Weight and activation distributions for different layers (conv2_1_1 and conv4_3_2) showing varying means and standard deviations.

Methodology

  1. Learnable Basis: A quantized value is represented as the inner product of this learnable basis vector and a binary encoding vector. This ensures the resulting network remains compatible with high-speed bitwise operations.
  2. Quantization Error Minimization (QEM): During the forward pass of training, the authors use a block coordinate descent algorithm to find the optimal basis and binary encoding that minimize the squared error between the full-precision data and its quantized version.
  3. Joint Training: The quantizers are optimized alongside the network weights. To handle the non-differentiable nature of quantization during the backward pass, they employ the Straight-Through Estimator (STE), which treats the gradient of the quantization function as an identity mapping.
  4. Flexibility: The method supports arbitrary bit-widths and can be applied independently to weights (channel-wise) and activations (layer-wise).

Performance and Key Results

The authors evaluated LQ-Nets on two standard computer vision benchmarks: CIFAR-10 and ImageNet (ILSVRC12). LQ-Nets consistently outperformed prior methods like DoReFa-Net and HWGQ across multiple architectures:

  • ResNet-50 on ImageNet: With 4-bit weights and 4-bit activations, LQ-Nets achieved 75.1% top-1 accuracy, coming within just 1.3% of the full-precision model (76.4%).
  • ResNet-18 on ImageNet: At 2-bit weights and 2-bit activations, it achieved 64.9% top-1 accuracy, a significant jump over previous methods.
  • VGG-Small on CIFAR-10: Using 1-bit weights and 2-bit activations, LQ-Nets reached 93.4% accuracy, nearly matching the full-precision reference of 93.8%.

By structuring the learnable quantizer as a linear combination of bits, the authors ensure the model still benefits from the $64\times$ theoretical speedup offered by bitwise operations on CPUs and GPUs without sacrificing accuracy.

Conclusion and Future Work

LQ-Nets demonstrates that the "bottleneck" in low-bit networks isn't just the lack of bits, but how those bits are utilized. By allowing quantizers to be adaptive, the network can "shape" itself to the data.

However, this performance comes with a training overhead. The QEM optimization adds computational cost; for a ResNet-18, training with 3-bit precision is roughly $3.7\times$ slower than training a full-precision model. Future work involves deploying these models on actual resource-constrained hardware to measure real-world power and latency gains, as well as optimizing the initialization of the learnable basis for faster convergence.

Summary updated

BibTeX
@inproceedings{zhang2018lq,
  author = {Dongqing Zhang and Jiaolong Yang and Dongqiangzi Ye and Gang Hua},
  title = {{LQ-Nets: Learned Quantization for Highly Accurate and Compact Deep Neural Networks}},
  booktitle = {European Conference on Computer Vision},
  year = {2018},
  url = {https://openreview.net/forum?id=S1Vo4cZ_-S},
}
Figure