VC Dimension & the Fundamental Theorem
Shattering, Sauer’s lemma and the characterization of learnability.
Finite VC dimension is the exact dividing line between classes that finitely many examples can teach and classes they cannot. This lesson proves the hard direction: a counting lemma that turns into a polynomial, a ghost sample that stands in for the unknown distribution, lower bounds showing the resulting rates cannot be beaten, and what all of it says, and fails to say, about neural networks.
What you’ll learn
- Prove the Sauer–Shelah lemma by induction, and explain why growth functions are either or polynomial.
- Prove uniform convergence for classes of finite VC dimension by ghost-sample symmetrization and random swaps, with explicit constants.
- State the realizable and agnostic lower bounds and describe the distributions that force them.
- Apply the VC-dimension bounds for piecewise-linear networks, and explain why class-level bounds are vacuous for modern networks.
Counting labelings: the Sauer–Shelah lemma
Throughout, is a class of binary classifiers with the 0–1 loss, and is the sample size. The growth function is at most , with equality exactly when some -point set is shattered; so for . Write for the number of subsets of an -set with at most elements.
Base cases. If , no point receives both labels, so all hypotheses agree on every point and a sample admits a single labeling. If and , there are at most two labelings, and .
Inductive step. Fix , let and . Let be the set of label vectors on obtained by deleting the last coordinate from vectors in , and the vectors on that occur in followed by a 0 and followed by a 1. Counting by its restrictions to , each vector of accounts for one or two members of , so
lives on points with VC dimension at most . If shatters some , the paired extensions supply both labels of , so shatters ; hence has VC dimension at most . The induction hypothesis applies to both:
Pascal's rule (with ) closes the induction:
Closed form. For , multiply each term by , extend the sum to all , and use the binomial theorem and :
Axis-aligned rectangles in the plane have VC dimension 4. Twenty points admit million labelings; what is the most that rectangles could produce, according to the Sauer–Shelah lemma?
Show the answer
6196 labelings
, about 0.6% of all labelings. The cruder is also polynomial.
Uniform convergence by a ghost sample
The difficulty is a supremum over an infinite class of deviations from an unknown distribution. Two tricks remove both obstacles. First, compare the training sample with an independent ghost sample of the same size, instead of with . Second, randomly swap the -th points of the two samples, which does not change their joint law. After conditioning on the points, only finitely many labelings remain. This is symmetrization, the argument of Vapnik and Chervonenkis.
Ghost sample. Suppose , attained (up to an arbitrarily small slack) by some that depends on only. Given , averages fresh Bernoulli variables with variance at most , so Chebyshev gives . With conditional probability at least , therefore, :
Random swaps. Write . Exchanging with leaves the joint law of unchanged, so independent uniform signs can be inserted for free:
Finitely many patterns. Given the points, matters only through its labels on them: at most loss vectors. For each one, , and Hoeffding's inequality over the signs (each term ranges over an interval of length ) gives
Combine. A union bound over the patterns and the factor 2 from the first step give the theorem. Setting the right side to gives , so the condition of the first step holds automatically; Sauer–Shelah supplies .
Think first The Descent lesson quoted , while this proof gives , roughly twice as large. Which is right?
Both. They come from different proofs: the one above loses a factor 2 to Chebyshev and halves in the symmetrization, which costs a factor 4 under the square root; the Rademacher route concentrates the supremum with McDiarmid's inequality and bounds its mean with Massart's lemma (Rademacher Complexity). Neither set of constants is sharp. What is robust is the rate , and even its logarithm is an artifact: chaining removes it.
Removing the logarithm. Chaining, through Dudley's entropy integral, combined with the covering-number bound for a class of VC dimension , gives for an absolute constant (Vershynin 2018, Theorems 8.3.18 and 8.3.23; the loss class has the same growth function as ). With a concentration step (McDiarmid) this yields the agnostic upper bound of the fundamental theorem. Shalev-Shwartz & Ben-David (2014, §28.1) prove only the slightly weaker , by the route of this lesson, and leave the chaining argument out.
Which step of the proof turns a supremum over an infinite class into a finite union bound?
- Chebyshev's inequality on the ghost sample
- Conditioning on the points of , on which realizes at most labelings
- Hoeffding's inequality over the random signs
- Taking expectations over the training sample
Show the answer
B. Conditioning on the points of , on which realizes at most labelings
Once the points are fixed, two hypotheses with the same labels on them have identical losses, so the supremum is a maximum over at most patterns. Before symmetrization, the deviation depends on everywhere on , through .
Lower bounds: the rates cannot be beaten
Take a shattered set . Put mass on and spread evenly over the rare points. Draw the target uniformly among the labelings of the rare points; all are realized by because the set is shattered.
With examples, the expected number of draws that land on rare points is , so in expectation at least three quarters of the rare points are never seen.
On an unseen point the target's label is a fair coin independent of the sample, so any learner errs there with probability . The unseen points carry mass at least :
An expected error of against a random target forces some fixed target in to cause error above with constant probability (the probabilistic method); the careful accounting gives the constants and .
The agnostic construction uses noise instead of unseen points. Each of shattered points carries mass and a label that is a coin of bias , the sign chosen at random. The best hypothesis predicts each point's majority label, and every wrong guess costs of excess risk. Telling a coin of bias from one of bias takes about flips, but each point receives only about ; with a constant fraction of the guesses is wrong, for excess risk of order .
In the realizable construction, why can no learner, however clever, predict the labels of the unseen rare points?
- Because the learner is restricted to empirical risk minimization
- Because the labels of the rare points are noisy
- Because the set is shattered: every labeling of the unseen points is consistent with the sample and realized by some hypothesis in , so the sample says nothing about them
- Because the rare points lie far from
Show the answer
C. Because the set is shattered: every labeling of the unseen points is consistent with the sample and realized by some hypothesis in , so the sample says nothing about them
Shattering means the labels on unseen points are unconstrained by the labels on seen ones. With the target drawn at random, those labels are independent fair coins given the sample, and every learner is reduced to guessing. This is the no-free-lunch argument run inside a single class.
The VC dimension of neural networks
Depth matters, and how much depends on the activation: the dependence on depth is absent for piecewise-constant activations (threshold units), linear for piecewise-linear ones, and at most quadratic for piecewise-polynomial ones (Bartlett et al., 2019). Roughly, every weight can store about bits, and depth lets later layers extract them, the "bit extraction" idea behind the lower-bound construction.
Think first Dziugaite & Roy (2017) trained fully connected networks with 0.3 to 2.4 million parameters on 55,000 MNIST images relabeled into two classes, reaching test errors below 2%. Their table lists best-known VC upper bounds of 26 to 187 million for these architectures. What can a VC bound say about these networks?
Nothing useful. A VC bound needs an upper bound on , and the best available ones exceed by a factor of hundreds or more: the polynomial regime of Sauer–Shelah never starts, may be as large as , and every resulting bound exceeds 1. Nor is this a failure of loose constants alone: Zhang, Bengio, Hardt, Recht & Vinyals (2017) showed that standard networks fit randomly relabeled training sets, so whatever certifies generalization on real labels must look beyond the class, at the data and the trained weights. Dziugaite & Roy's own bound, computed with PAC-Bayes, was nonvacuous (Stability, Compression & PAC-Bayes).
Key takeaways
- Sauer–Shelah: , so growth functions are either or polynomial, and the bound is attained.
- Symmetrization with a ghost sample and random swaps gives for , hence a gap of order ; chaining removes the logarithm.
- Lower bounds match: any learner can be forced to error above in the realizable case and excess risk above in the agnostic case, so the rates and are tight up to constants.
- ReLU networks with weights and layers have VC dimension , and some reach ; for modern networks , and class-level bounds say nothing.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Thresholds on the line have VC dimension 1. How many labelings can they produce on distinct points, compared with the Sauer–Shelah bound ?
- , far above the bound
- , one below the bound
- , exactly the bound
- , twice the bound
Show the answer
C. , exactly the bound
Sort the points: a threshold labels a suffix with 1, and the suffix can start before the first point, between any two neighbors, or after the last one, which gives labelings. That equals , so the Sauer–Shelah bound is attained and cannot be improved in general.
Which of these cannot be the growth function of any class of binary classifiers?
- for all
Show the answer
C.
equals for but not , so the VC dimension would be 2, and Sauer–Shelah would cap growth at ; yet eventually exceeds every polynomial. The other three are realized by a class of infinite VC dimension, by thresholds, and by intervals.
What does the ghost sample accomplish in the proof of the VC inequality?
- It replaces the unknown risk by an empirical average on independent data, so the deviation depends only on observed points
- It doubles the training set, which halves the error
- It provides a validation set for choosing the hypothesis
- It removes the need for a union bound
Show the answer
A. It replaces the unknown risk by an empirical average on independent data, so the deviation depends only on observed points
depends on the whole distribution, so the supremum over cannot be reduced to finitely many cases. After symmetrization everything depends on , and restricted to those points has at most behaviors.
Two ReLU architectures have the same number of weights; one has 2 layers and the other 20. What do the Bartlett–Harvey–Liaw–Mehrabian results say about their VC dimensions?
- They are equal, because VC dimension depends only on the number of weights
- The deeper one can be larger, by up to a factor of about the depth: the upper bound grows like , and constructions reach up to a constant
- The deeper one is smaller, because each layer has fewer weights
- Both are infinite, because ReLU networks are universal approximators
Show the answer
B. The deeper one can be larger, by up to a factor of about the depth: the upper bound grows like , and constructions reach up to a constant
For piecewise-linear activations the VC dimension can grow linearly with depth at a fixed number of weights, and the lower-bound construction shows this growth really happens. For threshold units, by contrast, depth does not enter.
Further reading
- V. N. Vapnik & A. Ya. Chervonenkis, "On the uniform convergence of relative frequencies of events to their probabilities," Theory of Probability and Its Applications 16(2), 264–280 (1971).
- N. Sauer, "On the density of families of sets," Journal of Combinatorial Theory, Series A 13(1), 145–147 (1972).
- A. Ehrenfeucht, D. Haussler, M. Kearns & L. Valiant, "A general lower bound on the number of examples needed for learning," Information and Computation 82(3), 247–261 (1989).
- P. L. Bartlett, N. Harvey, C. Liaw & A. Mehrabian, "Nearly-tight VC-dimension and pseudodimension bounds for piecewise linear neural networks," Journal of Machine Learning Research 20(63), 1–17 (2019).
- S. Shalev-Shwartz & S. Ben-David, Understanding Machine Learning: From Theory to Algorithms (Cambridge University Press, 2014), chapters 6 and 28.