On-the-fly Network Pruning for Object Detection

Marc Masana, Joost van de Weijer, Andrew D. Bagdanov

Abstract

Deep neural networks are typically trained as generalists, yet individual inference tasks often involve only a small subset of learned categories. This paper presents a dynamic, on-the-fly network pruning method for object detection that identifies and removes inactive neurons based on the specific content of an input image. By assessing activations at the pool5 layer, the method prunes redundant units in fully-connected layers during test-time. Experimental results on PASCAL VOC 2007 using the Fast R-CNN framework demonstrate that 25-40% of parameters in the $fc6$ layer can be removed with negligible impact on mean Average Precision (mAP).

Introduction

Modern object detection frameworks, such as Fast R-CNN, extract and process thousands of candidate bounding boxes from a single image. While these models are trained to recognize a wide variety of classes, any given image typically contains only a tiny subset of these categories. For instance, in an indoor scene, neurons specialized for detecting outdoor elements like "snow" or "rivers" remain inactive, yet the system continues to spend computational cycles calculating their activations for every candidate box. This paper addresses this "wasted computation" by proposing a method to prune the network dynamically for each specific image.

Methodology

The authors propose a two-step "assessment and prune" approach to optimize the forward pass during inference:

  1. Quick Assessment: Before processing individual bounding boxes, the entire image is passed through the convolutional layers. The resulting activations at the pool5 layer are analyzed to determine which features are present in the scene.
  2. Unit Pruning: If a neuron shows near-zero activation across the entire image, it is deemed unlikely to contribute to the classification of any sub-region. The authors implement two types of pruning to shrink the weight matrices of fully-connected layers ($fc6$ and $fc8$):
  3. Backward Unit Pruning: Removing the rows in the weight matrix ($W^k$) and bias vector ($b^k$) corresponding to inactive units in layer $k$.
  4. Forward Unit Pruning: Removing the columns in the weight matrix of the subsequent layer ($W^{k+1}$) that correspond to those inactive units.
Illustration of the backward row and forward column removal process during dynamic pruning.

Experimental Results

The researchers evaluated the approach using the PASCAL VOC 2007 benchmark and a VGG16 architecture within the Fast R-CNN framework. The $fc6$ layer, which contains nearly 39% of the total network parameters, was identified as the primary target for computational savings.

Key findings include:

  • Efficiency vs. Accuracy: In the $fc6$ layer, 25-40% of parameters could be removed with an mAP loss of less than 1 point.
  • Pruning Strategy: As shown in the performance analysis, the proposed unit pruning significantly outperforms random pruning, maintaining higher accuracy at much higher pruning ratios.
  • Class-Specific Pruning: For the output layer ($fc8$), a top-$N$ strategy (keeping only the 6 most likely classes) reduced parameters by 70% with minimal impact on results.
mAP loss relative to the proportion of original units removed, comparing unit pruning to random pruning across different layers.

Discussion and Conclusion

The core insight of this work is the exploitation of shared context; bounding boxes from the same image are highly correlated, allowing for a global decision on network relevance. Interestingly, the authors noted that removing very weak signals sometimes acted as a form of denoising, leading to minor performance improvements.

While the current study focuses on fully-connected layers, the theoretical framework is applicable to convolutional layers. Future research may explore scaling this to datasets with larger label sets (like ImageNet), where the sparsity of activations per image is expected to be even higher, offering even greater potential for on-the-fly optimization.

Summary updated

BibTeX
@misc{masana2016fly,
  author = {Marc Masana and Joost van de Weijer and Andrew D. Bagdanov},
  title = {{On-the-fly Network Pruning for Object Detection}},
  year = {2016},
  eprint = {1605.03477},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1605.03477},
}
Figure