Paper commentary
Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman Coding
Pruning, weight sharing and Huffman coding shrink AlexNet storage 35×
- Problem Large neural networks are too big to store and run on mobile and embedded hardware. Fetching weights from off-chip DRAM also costs too much energy.
- Method Deep Compression is a three-stage pipeline. It prunes low-weight connections, clusters the remaining weights into shared values, then applies Huffman coding.
- Results On ImageNet, AlexNet storage fell 35 times, from 240MB to 6.9MB, with Top-1 Error unchanged at 42.78%.
Why large networks are hard to ship and run
Storage is the first obstacle. The AlexNet Caffe model is over 200MB and the VGG-16 model is over 500MB, which makes deployment on a mobile system hard. App stores also treat large binaries with suspicion, so a feature adding 100MB draws far more scrutiny than one adding 10MB.
Energy is the second obstacle, and memory access dominates it. Under 45nm CMOS, a 32-bit DRAM access takes 640pJ, while a 32-bit floating point add takes 0.9pJ.
Pruning alone had already removed many connections from state-of-the-art CNNs with no loss of accuracy. The open question was whether pruning, weight sharing and entropy coding could be stacked for a much smaller footprint. Such a footprint could fit all weights in on-chip SRAM rather than off-chip DRAM.
How the approach differs from hashing and low-rank methods
HashedNets groups connection weights with a hash function before training, so the grouping is fixed in advance. The authors instead decide the sharing after full training, so the shared values approximate the trained network.
SVD is cheap to run but compresses weakly, reaching 5× on AlexNet with a Top-1 Error of 44.02%. Against that baseline, the pipeline's larger compression is the reason the comparison matters.
Three stages that compress a trained network
The key idea is that pruning and trained quantization do not interfere, so their savings can combine. Deep compression runs in three stages: pruning, quantization with weight sharing, and Huffman coding. After the first two stages, only the codebook and the indices have to be stored.
Pruning starts by training the network normally to learn which connections matter. Connections whose weights fall below a threshold are removed, and the remaining sparse connections are retrained. This cut the number of connections by 9× to 13× for AlexNet and VGG-16.
The sparse structure is kept in CSR or CSC format, which needs \(2a + n + 1\) numbers, where a is the non-zero count and n the number of rows or columns. To save more, the index differences are stored in 8 bits for CONV layers and 5 bits for FC layers. When a gap is too large for those bits, a filler zero is inserted.
Weight sharing clusters each layer's weights with k-means, so weights in the same cluster share one value. The clustering minimizes the within-cluster sum of squares, and each connection keeps only a small index into the shared table.
During fine-tuning, the gradients of all connections in one bin are summed and subtracted from the shared value, scaled by the learning rate. Each shared weight therefore learns from every gradient that falls into its bucket. The indices stay fixed while the codebook values move.
Huffman coding runs last, offline, after all fine-tuning has finished. It gives shorter codes to more frequent values, and it saves 20% to 30% of network storage on these skewed distributions.
Choosing the starting centroids
Initialization decides where the k-means centroids start, and that choice affects the accuracy of the quantized network. After pruning, the weights of AlexNet conv3 form a bimodal distribution, which makes the start point matter.
Forgy initialization picks k observed weights at random, so the centroids pile up around the two peaks. Density-based initialization spaces the CDF evenly, which puts centroids near the peaks but spreads them less evenly than Forgy. Linear initialization spaces the centroids evenly between the minimum and maximum weight, so it does not depend on the distribution.
Large weights matter more than small ones, yet there are few of them. Random and density-based starts seldom give those few large weights a large centroid.
Across 2 to 8 bits, linear initialization beats the other two methods in every case except 3 bits.
How many bits each layer needs
For pruned AlexNet, 8-bit CONV layers and 5-bit FC layers showed no loss of accuracy. Dropping to 8 bits for CONV and 4 bits for FC added only 0.01% Top-1 Error, which the authors call negligible and more hardware friendly. Going to 4 bits for CONV and 2 bits for FC raised Top-1 Error by 1.99% and Top-5 Error by 2.60%.
The bit budget depends on layer type, because CONV layers need more precision than FC layers. For CONV layers accuracy drops significantly below 4 bits, while FC layers hold up until about 2 bits.
Why pruning and quantization stack
Pruning alone or quantization alone starts losing accuracy below about 8% of the original size. Combined, the network reached about 3% of its original size with no loss of accuracy.
The dashed and solid curves for quantization with and without pruning differ very little. At 3 bits the pruned network can even beat the unpruned one on the left plot.
ImageNet compression results
The reference AlexNet has 61 million parameters, and the compressed model keeps the same Top-1 Error of 42.78%. Storage falls from 240MB to 6.9MB, which the authors report as a 35× compression. Huffman coding adds an extra 22% on top of pruning and quantization, which gives 35× in total.
Taken on its own, the pipeline reaches 2.88% of the original size. Against SVD, which reached 5× with a Top-1 Error of 44.02%, pruning with quantization reaches 27× before Huffman coding.
VGG-16 is a harder test, with a 49× compression that takes storage from 552MB to 11.3MB. Its Top-1 Error moved from 31.50% to 31.17%, and its Top-5 Error from 11.32% to 10.91%. The authors report no loss of accuracy for either network, and both error rates went down slightly.
LeNet results on MNIST
LeNet-300-100 went from 1.64% to 1.58% Top-1 Error at a 40× compression rate. LeNet-5 went from 0.80% to 0.74% Top-1 Error at 39×. For LeNet-300-100, pruning and quantization gave 32×, and Huffman coding raised it to 40×.
Speed and energy of compressed fully connected layers
The authors benchmarked FC6, FC7 and FC8 of AlexNet and VGG-16, because fully connected layers hold more than 90% of the model size. The three platforms were the NVIDIA GeForce GTX Titan X, the Intel Core i7-5930K and the NVIDIA Tegra K1.
At batch size 1, the pruned layers averaged a 3× speedup on CPU, 3.5× on GPU and 4.2× on mobile GPU. The authors attribute the gain to a smaller memory footprint, since VGG-16 FC6 alone is about 400MB and far larger than the L3 cache.
Energy, computed as power times computation time, fell 7× on CPU, 3.3× on GPU and 4.2× on mobile GPU. The energy values are normalized to CPU, and the pruned layers use 3× to 7× less energy overall at batch size 1.
With batching, the pruned network no longer shows its advantage, because batching lets the weights be blocked and reused.
Limits of the evidence
The quantized model was not benchmarked on CPU or GPU, because the available BLAS and sparse libraries don't support indirect lookup or the relative index. The benchmarks cover only FC6, FC7 and FC8 at batch size 1, so convolutional layers are not measured.
Accuracy was measured on four networks, two on MNIST and two on ImageNet. No other architectures appear in the reported experiments.
The authors name custom GPU kernels and a custom ASIC as ways to run the compressed format. They expect energy in such an ASIC to be dominated by on-chip SRAM access, but this expectation is not measured.
Paper info
- Authors
- Song Han, Huizi Mao, William J. Dally
- Venue
- arXiv · Preprint
- First published
- 2015-10-1
- Added
- 2026-11-11
- Updated
- 2016-2-15
- Version
- v5
- arXiv
- 1510.00149
- Category
- cs.CV · cs.NE
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Song Han, Huizi Mao, William J. Dally (2015). Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman Coding. arXiv:1510.00149v5. https://arxiv.org/abs/1510.00149v5
BibTeX
@misc{han2015deep,
title = {{Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman Coding}},
author = {Song Han and Huizi Mao and William J. Dally},
year = {2015},
eprint = {1510.00149},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1510.00149v5}
}