The Impact of Activation Sparsity on Overfitting in Convolutional Neural Networks

Karim Huesmann, Luis Garcia Rodriguez, Lars Linsen, Benjamin Risse

TL;DR

Overfitting in Convolutional Neural Networks (CNNs) isn't just a divergence in loss curves; it’s preceded by a measurable surge in "activation sparsity" within feature extraction layers. By introducing a new metric called Neural Activation Sparsity (NAS), researchers can detect overfitting in real-time and even prevent it by penalizing sparse activations, outperforming traditional regularizers like Dropout and L1/L2.

What Problem Does This Paper Address?

We usually identify overfitting by watching the gap between training and test loss. However, this "black box" approach doesn't explain the internal dynamics of the network. Furthermore, the standard assumption that sparsity is a desirable property (often inspired by biological brains) is increasingly being questioned.

The authors argue that high activation sparsity—where only a few neurons fire for a given input—actually represents an underutilization of a network's capacity. When a model becomes too sparse too early, it stops learning diverse, discriminative features and starts "memorizing" specific training samples. The challenge is to find a way to measure this internal state and use it to improve generalization.

Methods

The researchers introduce three core components to study and control these dynamics:

  1. Neural Activation Sparsity (NAS): Unlike traditional measures that simply count zeros after a ReLU activation, NAS is calculated before the nonlinearity. It uses a perplexity-based formula. By applying a Softmax to the activation vector of a receptive field and calculating its perplexity, the authors can determine how "concentrated" the network's attention is. High NAS means only one or two filters are doing the work; low NAS means the work is distributed across many filters (dense activations).
  2. Explainable AI (XAI) Visualizations: To make these dynamics visible, the paper proposes three visualization techniques:
  3. NAS Heatmaps: Spatially localized maps showing where sparsity occurs on an image.
  4. NAS Line Plots: Tracking the median sparsity of individual layers over training epochs.
  5. NAS Stripe Plots: A condensed 1D heatmap showing sparsity across dozens of layers simultaneously.
  6. NASReg (Regularization): Because the NAS metric is differentiable, the authors turned it into a loss penalty. NASReg explicitly penalizes high sparsity in feature extraction layers, forcing the network to maintain dense activations and utilize more of its parameters.
Fig. 1. NAS and NAS Heatmap generation. Left: sample input image. Middle: schematic network architecture and sketch of an exemplary proximate receptive field from the conv2 layer and the corresponding receptive field activation vector in conv3 layer. Right: NAS Heatmap extracted by calculating the activation sparsity on the depicted receptive field activation vector.

Datasets

The primary experiments were conducted on CIFAR-100, a dataset notorious for being susceptible to overfitting due to its relatively small number of images per class. To prove that NAS is a robust indicator even when standard assumptions fail, the authors also created a distorted test set (mixing 50% training data into the test set) to show that NAS still correctly identifies internal overfitting even when the test loss curve looks deceptively healthy.

Key Insights and Ideas

  • Sparsity as a Leading Indicator: The most striking finding is that NAS in the middle layers of a CNN often jumps sharply just before the test loss begins to rise. This makes it a potential "early warning system" for overfitting.
  • The Capacity Paradox: While pruning (weight sparsity) is often used to compress models, this paper shows that activation sparsity is a sign of failure. Dense activations allow the model to learn more robust, discriminative features.
  • Regularizers and Sparsity: The study reveals that traditional L1 and L2 regularization actually encourage high NAS, which might explain why they sometimes struggle to prevent overfitting compared to Batch Normalization, which tends to stabilize and lower NAS.
Fig. 2. Visualisations of layer NAS over time at three levels of aggregation with corre- sponding test loss (red): (a) NAS Heatmaps showing spatial sparsity distributions for 3 layers. (b) NAS Line Plot showing blue lines (and bands) of layer NAS values. (c) NAS Stripe Plot for 50 layers encoding layer NAS in 1D colour coded stripes.

Key Results

  • Superior Accuracy: On CIFAR-100, the NASReg approach achieved a peak accuracy of 51.19%, significantly outperforming the baseline VanillaNet (38.51%), Dropout (40.34%), and L1/L2 methods (which hovered between 28-32%).
  • Extended Training: While standard models began overfitting before epoch 20, models trained with NASReg showed no signs of generalization error even when trained for 300 epochs.
  • Architectural Consistency: The correlation between rising NAS and overfitting was confirmed across diverse architectures, including VGG16, ResNet50, and Xception.

Limitations and Future Work

The authors acknowledge that while NASReg is powerful, it requires careful hyperparameter tuning ($\lambda_i$) to ensure the network doesn't become too dense (which could lead to highly correlated, redundant filters).

Future research directions include:

  • Testing NAS dynamics with adaptive optimizers like ADAM.
  • Applying these metrics to more complex and modern architectures.
  • Further investigating the specific mechanism by which Batch Normalization stabilizes activation sparsity.

Summary updated

BibTeX
@inproceedings{huesmann2020impact,
  author = {Karim Huesmann and Luis Garcia Rodriguez and Lars Linsen and Benjamin Risse},
  title = {{The Impact of Activation Sparsity on Overfitting in Convolutional Neural Networks}},
  booktitle = {Workshops @ ICPR},
  year = {2020},
  doi = {10.1007/978-3-030-68796-0\_10},
}
Figure