TL;DR
This paper introduces a novel "class-based quantization" (CQ) method for deep neural networks (DNNs). CQ determines the optimal bit-width for individual filters or neurons based on their importance to different classes in the dataset, allowing for significant model compression while maintaining high accuracy. This approach offers a more fine-grained and efficient way to quantize DNNs compared to existing methods.
What Problem Does This Paper Address?
Deep neural networks (DNNs) have achieved remarkable performance in various tasks, but their large size and computational demands make them challenging to deploy on resource-constrained devices like mobile phones. Quantization is a key technique to address this by reducing the precision of weights and activations, thereby decreasing model size and inference time. However, existing quantization methods often fall into two categories: model-wise/layer-wise uniform quantization, which is too coarse-grained, or non-uniform quantization, which is hardware-intensive. While multi-bit quantization (assigning different bit-widths to different parts of the network) offers more flexibility, efficiently determining these bit-widths remains a significant challenge. This paper aims to bridge this gap by proposing a fine-grained, class-aware method for assigning optimal bit-widths to individual network components.
Methods
The core of this paper is the Class-based Quantization (CQ) method. It operates in several stages:
- Importance Score Calculation:
- Neuron Importance: For each neuron, an importance score is calculated based on its contribution to different classes. This is done by measuring the change in the network's output when the neuron's activation is set to zero. To reduce computational cost, this is approximated using Taylor expansion and gradients from a single backpropagation pass.
- Filter Importance: The importance of a filter is determined by taking the maximum importance score among all neurons it connects to. This ensures that even if most neurons in a filter are less important, a single highly important neuron will elevate the filter's overall importance.
- Bit-width Arrangement Search:
- Filters/neurons are sorted based on their importance scores.
- A search algorithm then determines thresholds for these importance scores. Filters/neurons falling between thresholds are assigned specific bit-widths. This process iteratively adjusts thresholds to meet a target average bit-width while minimizing accuracy degradation. The search prioritizes reducing bit-widths for less important components.
- Refining Quantized Networks:
- After quantization, knowledge distillation is employed. A full-precision model "teaches" the quantized model, helping to recover lost accuracy. The straight-through estimator (STE) is used to enable backpropagation through the quantized weights.
Datasets
The proposed method was evaluated on the following datasets:
- CIFAR10
- CIFAR100
Key Insights and Ideas
- Class-Aware Importance: The fundamental insight is that a neuron's or filter's importance is not absolute but varies depending on the input class. CQ leverages this by assessing how critical a component is for recognizing specific classes.
- Fine-Grained Control: By assigning bit-widths at the filter or neuron level, CQ offers much finer control than layer-wise or model-wise quantization, leading to more efficient compression.
- Balancing Accuracy and Compression: The proposed search algorithm effectively balances the trade-off between reducing bit-widths and maintaining inference accuracy, a critical challenge in quantization.
- Hardware Friendliness: The paper focuses on uniform quantization, which is more practical for hardware implementation compared to non-uniform methods.
Key Results
The paper demonstrates that CQ achieves competitive or superior results compared to existing methods like Any-Precision Network (APN) and WrapNet (WN) across various network architectures (VGG-small, ResNet-20) and datasets (CIFAR10, CIFAR100).
- Accuracy Maintenance: CQ can maintain inference accuracy with significantly lower average bit-widths.
- Superior Performance: Under the same bit-width settings, CQ often achieves better accuracy than APN and WN. For example, on VGG-small with 3.0/3.0 and 4.0/4.0 bit-widths on CIFAR100, CQ even outperformed the floating-point baseline.
- Stability: CQ shows more stable accuracy with lower activation bit-width settings.
- Flexibility: The method effectively utilizes multi-bit quantization, assigning different bit-widths to different layers and filters based on their class importance.
Limitations and Future Work
- Computational Cost of Importance Calculation: While the paper uses an approximation via Taylor expansion and gradients, calculating importance scores still involves a backpropagation pass. Further optimization might be explored.
- Search Space Complexity: The search for optimal bit-width arrangements, though heuristic, can still be computationally intensive for very large networks.
- Future Work: The authors suggest that this class-based approach could be extended to other compression techniques like pruning, potentially leading to even greater efficiency. Exploring its application to different network architectures and tasks is also a natural next step.
Summary updated