TL;DR
Large image networks carry far more weights than they need, and each weight fetched from slow memory costs energy. Han, Pool, Tran and Dally showed that you can train a network, delete the connections with small weights, and retrain what remains, without losing accuracy. On ImageNet they cut the parameters of AlexNet from 61 million to 6.7 million and of VGG-16 from 138 million to 10.3 million.
Builds on: Convolutional Neural Network, L2 Regularization, Stochastic Gradient Descent · Leads to: Pruning, The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks
Why it mattered
Pruning was studied before this paper, mostly to reduce overfitting and model size. This paper tied pruning to a hardware constraint. Moving a 32-bit number from off-chip DRAM costs about 640 picojoules, while the same number in on-chip SRAM costs about 5 picojoules. A model that fits on chip avoids most of that cost. The recipe here, a few rounds of prune and retrain, became the standard way to shrink a network after training. It is the starting point for later work on sparse models and compression, including Quantization and Knowledge Distillation, and it prompted the question of whether the sparse structure can be trained from the start, which The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks takes up.
The problem
By 2015 convolutional networks had grown quickly. LeNet-5, from 1998, had under 1 million parameters and classified handwritten digits. The 2012 AlexNet entry to the ImageNet competition had about 60 million. A 2014 face model had about 120 million, and a network scaled up by Coates and colleagues had about 10 billion. Their storage, memory bandwidth and computation made them hard to run on phones and embedded systems.
The authors give a concrete estimate. Running a network with 1 billion connections 20 times per second, with each connection fetched from off-chip DRAM at 640 picojoules, takes watts for memory access alone. That is far beyond what a mobile device can supply. The question is whether the network can be made smaller without changing what it computes much.
Other routes existed. Low-rank approximations and quantization reduce the cost of each parameter, and the paper notes they can be combined with pruning. Methods that remove parameters using second-order information, such as Optimal Brain Damage and Optimal Brain Surgeon, were accurate but needed extra computation. The paper's goal is a simple method that uses ordinary training.
How it works
Here is the method on a toy layer with four weights. Pretend the trained weights of one layer are , , and , and we choose a threshold of . The authors set each layer's threshold from the spread of its weights, but a fixed number makes the steps easy to follow.
flowchart LR
A["Train the dense network"] --> B["Prune weights below the threshold"]
B --> C["Retrain the sparse network"]
C -->|"repeat for more compression"| B
C --> D["Deploy the sparse network"]
- Train. Train the full network with ordinary training, starting from random values. The goal is to learn which connections matter, not the final weight values. In the toy layer the trained weights are , , and . Check: four weights, all present.
- Prune. Remove every connection whose absolute weight is below . The weights and have absolute values and , so both go. The weights and stay. Check: two of four survive, so half the layer is gone.
- Retrain. Keep the surviving weights under a mask, so pruned connections stay at zero. Train the remaining two weights with a small learning rate. Suppose one gradient step moves to . Check: the surviving weights change, and the removed ones never return.
- Repeat or stop. Prune again with the new weights, retrain, and repeat while accuracy holds. Check: each round removes a fraction of what is left, so the savings compound.
In a real network the same steps run on every layer, each with its own threshold, and the mask is applied to every weight tensor. The next section writes the steps in symbols.
The math
For layer , let be its weights and let be the standard deviation of those weights. The paper sets the threshold for that layer to its quality parameter times .
Step 1 in symbols: training
Train the dense network to get weights that minimize the loss on the training data, using Stochastic Gradient Descent. The paper uses L2 Regularization in this phase. L2 pushes weights toward zero without making them exactly zero, which is why a threshold is needed.
Step 2 in symbols: the threshold and mask
For each layer, set and define
In the toy layer the threshold was fixed, so the rule reads: keeps the first weight, and removes the third.
Step 3 in symbols: masked retraining
Retraining minimizes the same loss, but the forward pass uses , so the gradient on a pruned weight is zero. The surviving weights start from their trained values, not from new random values. The paper argues this matters because convolutional features are fragile: reinitializing layers and retraining them loses accuracy that the surviving weights still carry.
Dropout after pruning
Dropout drops each unit with probability during training. Pruning also reduces capacity, so the paper lowers for retraining. Let be the number of connections in a layer with neurons in layer and in the layer before. Dropout acts on neurons, while the connection count varies quadratically with the neuron count, so the paper ties the dropout change to the connection counts and sets
where is the original dropout rate, is the rate during retraining, is the connection count before pruning, and is the count after retraining. If pruning keeps one ninth of the connections, the square root is , so . With the retraining rate becomes about .
Compression ratio and storage
The compression ratio is the number of original weights divided by the number of survivors. For AlexNet the paper reports 61 million and 6.7 million weights, a ratio of , which the paper reports as 9 times. The paper stores the sparse layers in sparse form with indices. The storage overhead is 15.6 percent, and relative indices need 5 bits in fully connected layers and 8 bits in convolutional layers. A Sparse Matrix format pays for itself only when most entries are gone.
Results
The paper prunes four networks: LeNet-300-100 and LeNet-5 on MNIST, and AlexNet and VGG-16 on ImageNet (ILSVRC-2012, with 1.2 million training and 50 thousand validation images). The implementation is in Caffe, with a mask added to each weight tensor, and the experiments ran on Nvidia TitanX and GTX980 GPUs. The reference models are from the Caffe model zoo.
| Network | Top-1 error (ref / pruned) | Top-5 error (ref / pruned) | Parameters (ref / pruned) | Compression |
|---|---|---|---|---|
| LeNet-300-100 | 1.64% / 1.59% | - | 267K / 22K | 12x |
| LeNet-5 | 0.80% / 0.77% | - | 431K / 36K | 12x |
| AlexNet | 42.78% / 42.77% | 19.73% / 19.67% | 61M / 6.7M | 9x |
| VGG-16 | 31.50% / 31.34% | 11.32% / 10.88% | 138M / 10.3M | 13x |
Three findings matter most.
- Accuracy holds. On every network the pruned model's top-1 error is equal to or lower than the reference, by at most 0.16 points (on VGG-16), and the other nets change by 0.03 points or less. The authors attribute the small improvements to pruning finding a better capacity and reducing overfitting.
- Weights and operations fall by different amounts. AlexNet keeps 11 percent of its weights but only about 30 percent of its floating point operations, roughly 3 times fewer. The convolutional layers, which do most of the computation, were pruned less than the fully connected layers, which hold most of the parameters. VGG-16 keeps 7.5 percent of its weights and 21 percent of its operations.
- Iteration helps up to a point. On AlexNet, iterative pruning reaches 9 times compression with no accuracy loss. A single aggressive pruning step reaches only about 5 times without loss.
The paper also reports two training trade-offs. Without retraining, accuracy begins to fall once about one third of the connections remain. The paper's "free lunch" without retraining is about 2 times compression. Retraining AlexNet took 173 hours on a Titan X, against 75 hours to train the original.
Some limits follow from the paper's own statements. The method is evaluated on image classification networks only. Layers differ in sensitivity: the first convolutional layer, which sees the 3-channel input, is the most sensitive, so the paper uses a lower threshold there. L1 regularization gives better accuracy directly after pruning, but L2 gives better accuracy after retraining, and using L1 for pruning and L2 for retraining did not beat L2 throughout. Finally, the paper says the benefit depends on hardware. It targets fixed-function hardware built for sparse networks, because general-purpose processors handle sparse computation poorly.
Reading guide
- Section 1, Introduction. Needs Convolutional Neural Network for the networks and Memory Hierarchy for why off-chip access costs more energy than on-chip access.
- Section 2, Related Work. Needs Hessian Matrix for Optimal Brain Damage and Optimal Brain Surgeon, and Quantization and Vector Quantization for the quantization methods the paper compares against.
- Section 3, Learning Connections in Addition to Weights. Needs L2 Regularization for the regularization comparison, Dropout for the dropout ratio change, and Fine-Tuning for retraining from retained weights. The vanishing gradient argument needs Vanishing Gradient Problem.
- Section 4, Experiments. Needs Stochastic Gradient Descent and Learning Rate for the retraining schedule. The VGG-16 results refer to Very Deep Convolutional Networks for Large-Scale Image Recognition (VGG) for the architecture.
- Section 5, Discussion. Needs Overfitting for the claim that pruning can slightly improve accuracy, and Sparse Matrix for the storage overhead analysis.
- Section 6, Conclusion. Summarizes the three steps and the compression numbers from Table 1.
Check yourself
QuestionName the three steps of the method, in order.Show answer
QuestionA layer has weights and the threshold is . Which weights survive, and what fraction of the layer remains?Show answer
QuestionThe paper reports that AlexNet's parameters fall from 61 million to 6.7 million. What is the compression ratio, and why does the paper not claim the same speedup in operations?Show answer
QuestionA researcher prunes a trained network by 80 percent, skips retraining, and reports that accuracy is unchanged. Is this consistent with the paper?Show answer
Sources
- Song Han, Jeff Pool, John Tran, William J. Dally, "Learning both Weights and Connections for Efficient Neural Networks," 2015. arXiv:1506.02626
- Song Han, Huizi Mao, William J. Dally, "Deep Compression," 2015. arXiv:1510.00149