Network Automatic Pruning: Start NAP and Take a Nap

Wenyuan Zeng, Yuwen Xiong, Raquel UrtasunarXiv 2021

Abstract

Network pruning can significantly reduce the computation and memory footprint of large neural networks. To achieve a good trade-off between model size and performance, popular pruning techniques usually rely on hand-crafted heuristics and require manually setting the compression ratio for each layer. This process is typically time-consuming and requires expert knowledge to achieve good results. In this paper, we propose NAP, a unified and automatic pruning framework for both fine-grained and structured pruning. It can find out unimportant components of a network and automatically decide appropriate compression ratios for different layers, based on a theoretically sound criterion. Towards this goal, NAP uses an efficient approximation of the Hessian for evaluating the importances of components, based on a Kronecker-factored Approximate Curvature method. Despite its simpleness to use, NAP outperforms previous pruning methods by large margins. For fine-grained pruning, NAP can compress AlexNet and VGG16 by 25x, and ResNet-50 by 6.7x without loss in accuracy on ImageNet. For structured pruning (e.g. channel pruning), it can reduce flops of VGG16 by 5.4x and ResNet-50 by 2.3x with only 1% accuracy drop. More importantly, this method is almost free from hyper-parameter tuning and requires no expert knowledge. You can start NAP and then take a nap!

Introduction

Deep neural networks are notoriously memory-hungry and computationally expensive, making them difficult to deploy on edge devices or in low-latency environments. While network pruning—removing redundant weights or entire channels—is a popular solution, existing methods are often labor-intensive. Most pruning techniques rely on simple heuristics, such as assuming small-magnitude weights are unimportant, and require human experts to manually tune the compression ratio for every single layer. Because different layers have vastly different sensitivities, this manual tuning is a frustrating process of trial and error. Furthermore, methods designed for fine-grained pruning (removing individual weights) rarely translate well to structured pruning (removing entire channels).

Network Automatic Pruning (NAP) addresses these challenges by providing a single, mathematically grounded framework that automatically determines what to prune and how much to prune per layer, allowing researchers to "start NAP and take a nap."

Methodology

NAP frames pruning as an optimization problem that balances training loss with model complexity (measured in parameter count or FLOPs). To determine which parameters to cut, NAP utilizes the second-order Taylor expansion of the loss function. Essentially, it asks: "If I remove this weight or channel, how much will the loss increase?"

Overview of the NAP framework showing the forward/backward passes and the K-FAC approximation used to calculate importance scores.

Solving this exactly requires computing and inverting the Hessian matrix, which is computationally intractable for modern networks. To bypass this, NAP introduces a clever approximation:

  1. Fisher Information Matrix: It uses the Fisher matrix as a proxy for the Hessian.
  2. K-FAC (Kronecker-factored Approximate Curvature): It uses K-FAC to approximate the Fisher matrix as a block-diagonal matrix, breaking it down into much smaller, easily invertible matrices based on the statistics of layer inputs and gradients.
  3. Automatic Layer Calibration: Because the block-diagonal approximation can skew importance scores between layers, NAP normalizes the importance scores within each layer. It then globally prunes the bottom $p$ percentile of parameters or channels across the entire network.

Experimental Results

The authors evaluated NAP across several datasets, including MNIST, CIFAR-10, and ImageNet (ILSVRC-2012). The primary benchmark for large-scale models involved AlexNet, VGG16, and ResNet-50.

Fine-Grained and Structured Pruning

For fine-grained pruning, NAP compressed AlexNet and VGG16 by 25x, and ResNet-50 by 6.7x on ImageNet with zero loss in accuracy. In structured pruning, which targets hardware acceleration by removing entire channels, NAP demonstrated significant advantages over previous methods.

Comparison of NAP with other structured pruning methods on VGG16 and ResNet50, demonstrating superior compression and accuracy retention.

As shown in the table, NAP reduced the FLOPs (theoretical speedup) of VGG16 by 5.4x and ResNet-50 by 2.3x with only a ~1% drop in accuracy. This translated to real-world GPU inference speedups of 2.74x for VGG16 and 1.4x for ResNet-50.

Key Insights

  • Automatic Layer Discovery: Without manual instruction, NAP naturally discovered that fully connected (FC) layers contain far more redundancy than convolutional layers, automatically applying harsher compression to FC layers.
  • Hyperparameter Robustness: NAP is remarkably insensitive to its own hyperparameters, such as the pruning fraction $p$. Different settings often converge to strikingly similar final architectures and accuracies.
  • Generalization: A network pruned on ImageNet classification retained enough representational capacity to serve as an effective backbone for object detection on PASCAL VOC 2007, outperforming previous pruning methods.

Conclusion

NAP provides a unified and automatic framework for neural network pruning that eliminates the need for tedious manual tuning. By leveraging K-FAC for efficient Hessian approximation, it achieves massive compression rates and real-world speedups with minimal performance degradation. Future work may address the limitations of the block-diagonal assumption by explicitly modeling cross-layer influences.

Summary updated

BibTeX
@misc{zeng2021network,
  author = {Wenyuan Zeng and Yuwen Xiong and Raquel Urtasun},
  title = {{Network Automatic Pruning: Start NAP and Take a Nap}},
  year = {2021},
  eprint = {2101.06608},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2101.06608},
}
Figure