Memorization Capacity
How many parameters it takes to fit any n labels, and why that is fewer than you think.
Fitting arbitrary labels sounds like it needs about parameters, one per label, and with one hidden layer it does. With depth, about parameters suffice, provided each of them carries about bits. Counting arguments show that both numbers are optimal, and they reveal where the information actually lives.
What you’ll learn
- Prove that a one-hidden-layer ReLU network with weights fits any labels on distinct points in , and state the matching lower bounds for one and two hidden layers.
- Derive the lower bound on parameters from the VC dimension of piecewise-linear networks, and the bit-counting bound .
- State the optimal construction of Vardi, Yehudai and Shamir with its separation assumption and its cost in precision, and sketch how it stores labels in weights and reads them out with depth.
- Relate capacity to practice: interpolation by overparameterized gradient descent, random-label experiments, and the measured knowledge capacity of language models.
Fitting n labels with n units
A single linear threshold unit in realizes about half of all labelings of points in general position, about two patterns per weight (Cover, 1965). One hidden layer gives capacity linear in its size: threshold units memorize any binary labels on points in general position (Baum, 1988); units of any bounded nonlinear activation with a limit at or fit distinct points with arbitrary real labels (Huang & Babri, 1998); ReLUs fit real labels on points in general position (Bubeck, Eldan, Lee & Mikulincer, 2020). Each of these units has incoming weights, so the parameter count stays of order . The cleanest statement is for ReLUs and arbitrary distinct points.
All hidden units share one direction . Each difference is nonzero, so the directions orthogonal to it form a hyperplane; any off these finitely many hyperplanes (almost every ) gives distinct projections. Relabel the points so the projections increase:
Interleave the thresholds with the sorted projections. Unit is then active on point exactly when , that is, when :
So is lower triangular with a positive diagonal , hence invertible, and the output weights solve a triangular system by forward substitution, whatever the labels:
The parameters are , the thresholds and the output weights . The same idea trades width for depth: split the sorted projections into groups, fit one group per layer and add a small subnetwork that selects the right group's output. For every this gives depth , width and still weights (Zhang et al., 2017, Corollary 1).
How many weights does this construction need to fit arbitrary real labels on distinct images of pixels ()?
Show the answer
2784 weights
. A small 784–256–10 classifier has over 200,000 parameters, seventy times more. Fitting arbitrary labels on a dataset of this size is cheap in parameters; what such a fit is worth is another question (The Generalization Puzzle).
For one hidden layer this is essentially optimal. Yun, Sra & Jadbabaie (2019) counted linear pieces of the network along a line: a one-hidden-layer ReLU network with units fails to fit some dataset of distinct points with labels in whenever , and a network with two hidden layers of widths fails whenever . Conversely, two hidden layers of width fit any such dataset. Hidden units can thus drop to about , but the weights between the two layers keep the parameter count linear.
Lower bounds: shattering and bits
A network that memorizes every labeling of points shatters them, so its class has VC dimension at least . For ReLU networks, and for any piecewise-linear activation, the VC dimension is known almost exactly (Bartlett, Harvey, Liaw & Mehrabian, 2019). With weights in layers:
Shattering. Memorizing all labelings of points needs . Every layer contains at least one weight, so , and the upper bound gives the first bound below. Goldberg and Jerrum's bound , which holds at any depth, removes the logarithm:
At a fixed depth the same bound reads . Shallow networks therefore need nearly linear parameter counts; only depth that grows with can bring the count down to .
Bits. Count functions instead of points. If each of the weights is stored in bits, a fixed architecture has at most settings, hence at most distinct functions. The binary labelings of points need distinct functions:
So a network with weights must give each of them about bits. Vardi, Yehudai & Shamir (2022) prove the refined bound and show that bits per weight are both necessary and sufficient for memorization with weights. Precision is the hidden currency of memorization.
A float32 network (32 bits per weight) must realize every one of the binary labelings of fixed points. By the bit-counting bound, how many weights does it need at the very least?
Show the answer
31250 weights
with gives . At standard precision memorization is linear in again, at best one weight per 32 labels. The sublinear constructions below need weights far more precise than any hardware stores.
Square-root memorization with depth
Between the constructions and the lower bound, depth closes the gap in stages:
| Result | Hidden units | Parameters | Depth | Assumption on the inputs |
|---|---|---|---|---|
| Zhang et al. (2017) | one hidden layer | distinct | ||
| Yun, Sra & Jadbabaie (2019) | two hidden layers | distinct; labels in | ||
| Park, Lee, Yun & Shin (2021) | — | for constant | grows with | -separated |
| Vardi, Yehudai & Shamir (2022) | width 12 | -separated, in a ball of radius |
Project. One unit projects the data onto a well-chosen unit vector that shrinks no pairwise distance too much. After shifting and scaling, the projections are distinct numbers at least 2 apart in :
Pack. Sort the projections and cut them into intervals of consecutive points. For interval , write the rounded positions of its points side by side in the binary expansion of one integer ( bits each) and their labels side by side in another integer ( bits each). These integers become weights, each of bits.
Find the interval. A constant-width subnetwork compares the input with the interval boundaries and outputs the integers of the interval it falls in:
Extract. A deep subnetwork reads one block of bits at a time, using compositions of Telgarsky's triangle function to peel off binary digits, the same tent map that built the sawtooth in What Networks Can Represent. When a block matches to within 1, which by the separation happens for exactly one point, it extracts the matching bits of and outputs them. Each digit costs a few layers of constant width, so the depth grows with the number of bits in one interval:
The square-root construction memorizes any points that are -separated. Yet for standard activations, networks with fewer than about parameters cannot shatter every set of points in general position (Sontag, 1997). Why is there no contradiction?
- Sontag's bound concerns only networks with a single hidden layer
- The construction memorizes only binary labels, while the bound concerns real-valued labels
- The lower bound may use points packed arbitrarily close together, while the construction assumes a separation and its size grows with
- The construction is randomized, so it memorizes only most datasets, not all of them
Show the answer
C. The lower bound may use points packed arbitrarily close together, while the construction assumes a separation and its size grows with
Sublinear memorization needs some assumption, and separation is the one used: enters the depth through , with . For a fixed parameter budget, sets packed tightly enough are out of reach, so the two results describe different families of inputs.
What training does with capacity
The constructions place weights by hand. Three threads connect them to networks trained by gradient descent.
Gradient descent finds interpolants. With enough width, gradient descent from random initialization drives the training loss of a two-layer ReLU network to zero on any inputs of which no two are parallel, at a linear rate (Du, Zhai, Póczos & Singh, 2019), and similar results hold for deep networks (Allen-Zhu, Li & Song, 2019). The widths these proofs need are large polynomials in , far above the constructions; the mechanism, a nearly fixed kernel, is the subject of Loss Landscapes. How fast labels are fitted depends on how they align with that kernel's top eigenvectors: true labels align well and random labels do not, so gradient descent fits random labels more slowly (Arora, Du, Hu, Li & Wang, 2019). Spectral Bias & Fourier Features develops this frequency picture.
Real networks memorize far below the bit budget. Zhang et al. (2017) trained an Inception-style network with 1.65 million parameters to 100% training accuracy on CIFAR-10's 50,000 images with random labels, taking only a small constant factor longer than with the true labels. Those labels carry bits: about 0.1 bit per parameter, against the 32 bits a float32 weight can hold.
Knowledge capacity. Allen-Zhu & Li (2025) trained language models on synthetic biographies and measured the stored facts in bits. They found about 2 bits per parameter, provided each fact appeared about 1,000 times in training; 8-bit quantization preserved this, while 4-bit quantization cut it by more than half. It is an empirical regularity on controlled data, not a theorem, but it places trained networks within a factor of 16 of the float32 counting bound, and very far from the -bit weights of the optimal constructions.
Capacity results say what a network can memorize. Whether memorizing hurts, and why fitting rare examples can be necessary for good accuracy, are questions about the data distribution, taken up in The Generalization Puzzle and Memorization & the Long Tail.
Key takeaways
- With one hidden layer, weights fit any labels on distinct points (project, sort, interleave the thresholds, solve a triangular system), and about units are also necessary.
- The VC dimension of ReLU networks forces for memorization, and at depth ; counting bits forces .
- With depth , width 12 and weights of bits, parameters memorize any -separated points (Vardi, Yehudai & Shamir, 2022). It is optimal up to logarithms, and possible only because each weight stores many labels.
- Trained networks use far less: overparameterized gradient descent interpolates readily, random labels on CIFAR-10 cost about 0.1 bit per parameter, and language models store about 2 bits of knowledge per parameter in controlled experiments.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
In the construction, what guarantees that the output weights can fit any labels?
- The projection direction is chosen by gradient descent to separate the labels
- Each hidden unit is active on exactly one data point
- Interleaving the thresholds with the sorted projections makes lower triangular with a positive diagonal, so is invertible
- The number of weights exceeds the number of labels, so a solution always exists
Show the answer
C. Interleaving the thresholds with the sorted projections makes lower triangular with a positive diagonal, so is invertible
Unit is active exactly on the points with , that is, on points . The resulting triangular system has a unique solution for every .
ReLU networks with weights and depth have VC dimension . What does this imply for networks that memorize every labeling of points?
- They need at least about weights, and about at fixed depth
- They need at least weights, whatever their depth
- They need at least weights
- Nothing, because VC dimension is about generalization rather than fitting
Show the answer
A. They need at least about weights, and about at fixed depth
Memorization requires . With , gives ; at fixed depth, . Goldberg and Jerrum's sharpens the first to , which Vardi et al. (2022) match up to a factor.
Why can't a float32 network with weights memorize arbitrary binary labels on points?
- Its VC dimension is exactly
- Float32 cannot represent the separation between the points
- A network with weights would need depth , and its gradients would vanish
- Its weights hold bits, but distinguishing all labelings takes bits
Show the answer
D. Its weights hold bits, but distinguishing all labelings takes bits
A fixed architecture with weights of bits computes at most functions, so is necessary. With and that is 32,000 bits against needed. The square-root constructions escape only by using weights of about bits each.
Zhang et al. (2017) fitted CIFAR-10's 50,000 training images with random labels using a network of 1.65 million parameters. About how many bits of label information is that per parameter?
- about 3.3
- about 0.1
- about 2
- about 32
Show the answer
B. about 0.1
Each random label among 10 classes carries bits, so the dataset holds about bits, or bit per parameter. The network used only a sliver of its storage.
Further reading
- C. Zhang, S. Bengio, M. Hardt, B. Recht & O. Vinyals, "Understanding deep learning requires rethinking generalization," ICLR (2017).
- C. Yun, S. Sra & A. Jadbabaie, "Small ReLU networks are powerful memorizers: a tight analysis of memorization capacity," NeurIPS (2019).
- G. Vardi, G. Yehudai & O. Shamir, "On the optimal memorization power of ReLU neural networks," ICLR (2022).
- P. L. Bartlett, N. Harvey, C. Liaw & A. Mehrabian, "Nearly-tight VC-dimension and pseudodimension bounds for piecewise linear neural networks," JMLR 20 (2019).
- Z. Allen-Zhu & Y. Li, "Physics of language models: Part 3.3, knowledge capacity scaling laws," ICLR (2025).