Network size and weights size for memorization with two-layers neural networks

Sébastien Bubeck, Ronen Eldan, Yin Tat Lee, Dan Mikulincer

This paper, titled "Network size and weights size for memorization with two-layers neural networks," provides a deep dive into the fundamental limits of what neural networks can "remember." While we often focus on how networks generalize to new data, understanding how they fit training data—the memorization problem—is a cornerstone of learning theory.

TL;DR

The authors show that a two-layer ReLU network can memorize $n$ data points in $d$ dimensions using nearly the optimal number of neurons ($\approx n/d$). Crucially, they introduce a "complex network" construction that achieves this with nearly optimal weight magnitudes ($O(\sqrt{n})$), significantly improving upon previous methods that required much larger weights.

What Problem Does This Paper Address?

In machine learning theory, a classic question is: How many neurons do you need to perfectly fit $n$ data points?

In 1988, Eric Baum showed that for binary labels, $n/d$ neurons are sufficient. However, simply counting neurons isn't enough. Modern theory suggests that the magnitude of the weights (the "total weight") is a better predictor of a network's behavior and generalization than the raw number of parameters.

Previous constructions for memorization typically resulted in "explosive" weights—magnitudes that grow very quickly with $n$. This paper asks if we can have the best of both worlds: a network that is small (few neurons) and stable (small weights).

Methods

The authors explore three different ways to build a memorizing network:

  1. Baum Networks (Combinatorial): A construction that uses hyperplanes to isolate groups of points. While efficient in neuron count, the authors prove these require very large weights ($n^2/\sqrt{d}$).
  2. NTK Networks (Kernel-based): Based on the Neural Tangent Kernel regime, where weights stay close to their random initialization. These also result in sub-optimal total weight ($n\sqrt{n}$).
  3. The Harmonic/Complex Network (The Innovation): This is the paper's main contribution. The authors use complex-valued weights and a "complex trick" to build the network.
  4. By perturbing neurons in the complex plane, they can use Taylor expansions to cancel out unwanted higher-order terms.
  5. They use Hermite polynomials as an intermediate activation function because they have clean orthogonality properties in Gaussian space.
  6. Finally, they show how to approximate these complex "harmonic" neurons using standard real-valued ReLU units.

The construction is iterative: they use a boosting-like procedure where they add neurons one by one to correlate with the remaining residual error until the data is memorized to the desired precision.

Datasets

This is a theoretical paper, so it does not use standard benchmarks like CIFAR-10 or ImageNet. Instead, it relies on mathematical assumptions about data distribution:

  • General Position: Points in $\mathbb{R}^d$ where no $d$ points lie on the same hyperplane.
  • Well-Spread Data: Points distributed on a unit sphere $S^{d-1}$ such that their mutual correlations are small ($|x_i \cdot x_j| \approx 1/\sqrt{d}$).

Key Insights and Ideas

  • The "Complex Trick": This is the "aha moment." In real-valued Taylor expansions, you can only cancel out even or odd terms using random signs. By moving to the complex plane ($a \in \mathbb{C}$), you can zero out all terms except the first-order term. This allows a single neuron to correlate much more strongly with the target labels without needing massive weights.
  • Weight vs. Size Trade-off: The paper formalizes the idea that you can't just look at the number of neurons. A "small" network with massive weights is effectively more complex than a "large" network with tiny weights.
  • Lower Bounds: The authors prove that for random data, any network that memorizes the labels must have a total weight of at least $\Omega(\sqrt{n})$. Their construction hits $O(\sqrt{n})$ (up to log factors), proving their method is nearly optimal.

Key Results

  • ReLU Memorization: They prove that $4n/d$ neurons are sufficient to fit arbitrary real labels (generalizing Baum's binary result).
  • Optimal Weight Magnitude: The proposed Harmonic Network achieves approximate memorization with $O(\frac{n}{d\epsilon} \text{polylog})$ neurons and a total weight of $\tilde{O}(\sqrt{n})$.
  • Weight Comparison: Standard NTK or Baum-style constructions require weights of magnitude at least $n\sqrt{n}$ or $n^2/\sqrt{d}$, respectively. The new construction is exponentially more "weight-efficient."

Limitations and Future Work

  • Complex to Real Gap: While the authors show how to convert complex neurons back to real ReLUs, the construction is mathematically involved and not something you would implement directly in PyTorch for a standard task.
  • Error Dependency: The dependency on the approximation error $\epsilon$ is slightly worse for the harmonic network ($1/\epsilon$) compared to the NTK network ($\log(1/\epsilon)$). The authors note this is a technical artifact of the variance in their construction that they don't yet know how to remove.
  • Structured Data: The results assume "well-spread" or random data. Real-world data often lies on low-dimensional manifolds. Extending these optimal weight bounds to structured data remains an open challenge.

Summary updated

Abstract

In 1988, Eric B. Baum showed that two-layers neural networks with threshold activation function can perfectly memorize the binary labels of $n$ points in general position in $\mathbb{R}^d$ using only $\ulcorner n/d \urcorner$ neurons. We observe that with ReLU networks, using four times as many neurons one can fit arbitrary real labels. Moreover, for approximate memorization up to error $\epsilon$, the neural tangent kernel can also memorize with only $O\left(\frac{n}{d} \cdot \log(1/\epsilon) \right)$ neurons (assuming that the data is well dispersed too). We show however that these constructions give rise to networks where the magnitude of the neurons' weights are far from optimal. In contrast we propose a new training procedure for ReLU networks, based on complex (as opposed to real) recombination of the neurons, for which we show approximate memorization with both $O\left(\frac{n}{d} \cdot \frac{\log(1/\epsilon)}{\epsilon}\right)$ neurons, as well as nearly-optimal size of the weights.
BibTeX
@inproceedings{bubeck2020network,
  author = {Sébastien Bubeck and Ronen Eldan and Yin Tat Lee and Dan Mikulincer},
  title = {{Network size and weights size for memorization with two-layers neural networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
  url = {https://openreview.net/forum?id=-Zxfinfu7_g},
}

Loading related content...

Figure