How Spurious Features are Memorized: Precise Analysis for Random and NTK Features

Simone Bombari, Marco Mondelli

Introduction

Deep learning models are notoriously prone to overfitting and memorizing "spurious" features—patterns in the training data that are entirely irrelevant to the actual task. For instance, a classifier might identify a "cow" not by its shape, but because there is green grass in the background. While humans easily distinguish the core subject from its environment, neural networks often latch onto these accidental correlations.

While numerous empirical studies have aimed at understanding this phenomenon, a rigorous theoretical framework to quantify it has been missing. This paper provides a precise mathematical characterization of how deep learning models memorize spurious features, specifically focusing on noise that is uncorrelated with the true label. By decomposing memorization into model stability and a novel "feature alignment" term, the authors prove that a model's tendency to latch onto noise is fundamentally linked to its generalization error and its specific activation function.

The Mechanics of Memorization

To establish a precise mathematical "ruler" for this phenomenon, the authors analyze memorization through the lens of Generalized Linear Regression, which covers two popular theoretical settings: Random Features (RF) and the Neural Tangent Kernel (NTK).

They model a data sample $z$ as a combination of a core feature $x$ (e.g., the main object) and a spurious feature $y$ (e.g., background noise).

Examples of full samples and isolated spurious features.

The core of their method is a mathematical decomposition showing that the memorization of a spurious feature can be broken down into two distinct components:

  1. Model Stability ($S_z$): A classical concept in learning theory that measures how much the model’s output changes if you remove a single training sample. It essentially dictates if a model is prone to overfitting.
  2. Feature Alignment ($\mathcal{F}$): A novel metric introduced in this paper. It measures the similarity in the model's internal "feature space" between a full sample (e.g., the core object plus the background) and just the spurious part (the background alone). This term explains what specific noise the model overfits to.

To derive precise bounds, the authors utilize high-dimensional probability tools (like the Hanson-Wright inequality) and expand activation functions into Hermite polynomials. This allows them to see exactly how the "shape" of an activation function influences whether a model ignores or memorizes noise.

Experimental Validation

The authors validated their theory using a mix of synthetic and standard benchmarks:

  • Synthetic Data: High-dimensional Gaussian vectors where the core and spurious components are mathematically defined.
  • MNIST & CIFAR-10: Standard image datasets (like digits or natural images of cats) modified with added "noise backgrounds" or borders to serve as the spurious features.
  • Architectures: Beyond the theoretical RF and NTK models, they tested their insights on fully connected networks, CNNs, and ResNet-18/ResNet-50 to demonstrate that the theory holds in practical, deep learning scenarios.

Key Insights and Results

The paper mathematically proves that memorization is proportional to generalization error. As a model gets better at its actual task (achieving lower generalization error), it naturally becomes less prone to memorizing spurious noise. As the number of training samples $N$ increases, test accuracy goes up, and spurious memorization goes down at an exact rate predicted by their theory.

The Role of the Activation Function

Perhaps the most surprising insight is the role of the activation function. The authors found that the Hermite coefficients of the activation function (or its derivative in the case of NTK) act as a gatekeeper. Activation functions that emphasize "high-order" patterns are less likely to align with simple spurious noise. In experiments on MNIST and CIFAR-10, changing the activation function to one with specific Hermite properties significantly reduced the model's reliance on spurious backgrounds without hurting its ability to learn the core task.

Predictive Power

The theoretical formulas derived for RF and NTK accurately predicted the "spurious accuracy"—how often the model correctly guesses a label based only on the noise—across different sample sizes.

Limitations and Future Directions

The authors acknowledge a few key boundaries to their current work:

  • Uncorrelated Noise: The study focuses on spurious features that have zero correlation with the label in the overall distribution. In the real world, spurious features are often "poisoned" (e.g., 90% of cows are actually on grass), presenting a more complex scenario.
  • Lazy Training Regime: The analysis is rooted in the "lazy" regime, where weights do not move far from initialization. While empirical results hold for ResNets, the rigorous math for the "feature learning" regime (where weights change drastically) remains an open challenge.

Future work will likely extend this framework to study "simplicity bias"—the tendency of models to learn the simplest possible patterns first, even if they are spurious.

Summary updated

BibTeX
@inproceedings{bombari2024how,
  author = {Simone Bombari and Marco Mondelli},
  title = {{How Spurious Features are Memorized: Precise Analysis for Random and NTK Features}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=o6N1Bqay0k},
}
Figure