Memory Capacity of Two Layer Neural Networks with Smooth Activations

Liam Madden, Christos Thrampoulidis

TL;DR

This paper provides a rigorous proof that two-layer neural networks with almost any practical activation function (sigmoids, tanh, ReLU, etc.) can memorize a dataset of size roughly half the number of its trainable parameters. By using novel algebraic techniques to analyze the rank of the network's Jacobian, the authors establish a lower bound for memory capacity that is optimal up to a factor of approximately two.

What Problem Does This Paper Address?

In machine learning, "memory capacity" refers to the largest size of a general dataset that a neural network can perfectly interpolate (memorize). Understanding this threshold is fundamental because it marks the transition between underfitting and overfitting, and it is central to the "double descent" phenomenon where generalization error improves even after a model has enough parameters to fit the training data perfectly.

While previous research established memory capacity bounds for specific, simple activations like the Heaviside (step) function or the Rectified Linear Unit (ReLU), a unified theory for "smooth" or "real analytic" activations—the kind actually used in modern deep learning (like GELU, Swish, or Sigmoids)—was largely missing or relied on overly complex probabilistic arguments. This paper seeks to provide a definitive, linear-algebraic answer for these smooth functions.

Methods

The authors shift the focus from specific activation properties to the generic rank of the network's Jacobian. The Jacobian is the matrix of partial derivatives of the network's output with respect to its weights. If this matrix has "full rank," the network is locally capable of mapping its inputs to any desired set of target labels.

Key technical components include:

  • Hadamard Powers and Khatri-Rao Products: The authors represent the Jacobian of a two-layer network using these specific matrix operations. A Khatri-Rao product is essentially a column-wise Kronecker product, and Hadamard powers are element-wise powers.
  • Generic Rank Analysis: They prove that for "generic" data (data that doesn't fall into a very specific, rare algebraic pattern), these complex matrix products maintain full rank.
  • Constant Rank Theorem: By showing the Jacobian is full rank at a specific point where the activation is "analytic" (can be represented by a power series), they use the Constant Rank Theorem from differential geometry to prove that the network can interpolate any target vector in a neighborhood.
  • Width Doubling: To turn a local existence proof into a global surjectivity result, they show that a network with $2m$ neurons can implement a scaled and shifted version of a network with $m$ neurons, effectively "covering" the target space.

Datasets

This is a theoretical paper; it does not use empirical datasets like MNIST or ImageNet for training or evaluation. Instead, it deals with "generic" data matrices $X \in \mathbb{R}^{d \times n}$. The results are intended to hold for almost any dataset one might encounter in the real world.

Key Insights and Ideas

  • Real Analyticity is the Key: You don't need a specific shape for an activation function to guarantee high memory capacity. As long as the function is "real analytic" at a single point (meaning it has a valid Taylor series expansion there) and isn't a low-degree polynomial, it will likely provide near-optimal capacity.
  • Algebraic Generality: The paper successfully generalizes results that were previously siloed. It covers sigmoids, tanh, arctan, GELU, and even ReLU (which is piecewise linear but analytic at points away from zero).
  • The "Aha" Moment on Rank: The authors discovered that the rank of the Jacobian is determined by the number of non-zero coefficients in the activation function's Taylor expansion. If the function has enough "non-linearity" (high-degree terms), the Jacobian will be full rank.
  • Simpler Proofs: Unlike prior works that used heavy probabilistic machinery (like the Matrix Chernoff Inequality), this paper uses classical linear algebra and differential geometry, leading to more precise results without "log factors" that often weaken probabilistic bounds.

Key Results

  • Lower Bound: For a network with $m$ hidden neurons and input dimension $d$, the memory capacity $n$ is at least $\lfloor md/2 \rfloor$.
  • Optimality: Since the total number of trainable parameters is $md + 2m$, and a network cannot memorize more data points than it has parameters, this result is optimal up to a factor of approximately 2.
  • Surjectivity: The paper proves that if $md \ge 2n$ and $m$ is even, the network mapping is "surjective" for generic data, meaning it can hit any target label vector exactly.
  • Tightness: They provide a matching upper bound (Theorem 5.4), showing that if $m(d+2) < n$, the network cannot be surjective for any data $X$.

Limitations and Future Work

  • The Factor of 2: There remains a gap between the lower bound ($md/2$) and the theoretical maximum ($md$). Closing this gap (showing that $n \approx md$ is possible) remains an open challenge.
  • Two-Layer Limit: The current analysis is strictly for two-layer architectures. While the authors suggest their approach "holds promise" for deeper models, the algebraic complexity of the Jacobian increases significantly with more layers.
  • Implicit vs. Explicit: The proof shows that an interpolating solution exists, but it doesn't provide a specific training algorithm (like a specific version of SGD) to find it. However, it does suggest that checking the Jacobian rank at initialization is a valid way to predict if a network can be trained to zero error.

Summary updated

BibTeX
@article{madden2024memory,
  author = {Liam Madden and Christos Thrampoulidis},
  title = {{Memory Capacity of Two Layer Neural Networks with Smooth Activations}},
  journal = {SIAM J. Math. Data Sci.},
  year = {2024},
  doi = {10.1137/23m1599355},
}
Figure