PAC-Bayes Generalization Bounds
Anchor (Master): Catoni 2007 PAC-Bayesian Supervised Classification (IMS Lecture Notes 56) (the Catoni bound, the optimal Gibbs/exponential-weights posterior minimising the bound, localisation, and the link to the thermodynamic free energy); Maurer 2004 arXiv (the clean binomial-KL PAC-Bayes bound); McAllester 1999 Machine Learning 37 and 2003 Machine Learning 51 (the some-PAC-Bayes theorems, derandomisation, and the Occam/MDL reading); Dziugaite & Roy 2017 Proc. UAI (non-vacuous PAC-Bayes bounds for stochastic neural networks by optimising the posterior)
Intuition Beginner
The earlier bounds in this chapter measured a whole family of rules by one capacity number and asked how badly the family could fool you. PAC-Bayes asks a different, friendlier question. You are allowed to keep not one rule but a whole belief about which rules are good — a way of assigning weight to each rule. You write down a belief before you see any data; call it your prior. Then you look at the data and update to a new belief, your posterior, putting more weight on rules that did well on the sample.
Now imagine flipping a coin against your posterior to pick a rule, and using that randomly chosen rule. PAC-Bayes bounds the average true error of this random pick. The bound says: the average true error is at most the average training error, plus a penalty. And the penalty is paid not for how complicated the rules are, but for how far your posterior strayed from your prior. Stay close to what you believed before the data, and the penalty is small. Move far, and you owe more evidence.
This is a fair trade. Changing your mind a lot in light of data is exactly the move that risks overfitting, so the bound charges you for it, measured by a gap between two beliefs. If your data genuinely support a big change, the lower training error pays for the larger penalty, and the bound still comes out small. That balance is why these bounds can be tight even for huge, flexible models.
Visual Beginner
Picture two clouds of weight over the space of rules. The pale cloud is your prior, spread out before any data. The dark cloud is your posterior, pulled toward the rules that fit the sample. The penalty in the bound is a measure of how much the dark cloud has shifted away from the pale one.
rules: r1 r2 r3 r4 r5
prior: . .. .. .. . (spread, pre-data)
post: . . .... ... . (pulled toward good fits)
^^^^ ^^^
penalty grows with how far post moved from prior
small move -> small penalty -> bound close to training error
big move -> big penalty -> need much lower training error| How far posterior moved from prior | Penalty | When the bound is still good |
|---|---|---|
| barely moved | tiny | training error already low |
| moderate move | moderate | data strongly favour the shift |
| huge move | large | only if training error drops a lot |
The picture teaches the lesson: you may revise your belief freely, but the bound charges you for the size of the revision, so honest evidence buys cheap revisions and overfitting buys expensive ones.
Worked example Beginner
Take a tiny menu of four rules and suppose your prior puts equal weight on each. After seeing the data you form a posterior that puts weight on the first rule and on each of the other three. We compute the penalty term, which compares posterior to prior.
Step 1. The comparison adds up, over the rules, the posterior weight times the logarithm of (posterior weight divided by prior weight). For rule one: weight times the log of divided by , which is the log of , about . So rule one contributes .
Step 2. For each of the other three rules: weight times the log of divided by . The ratio , whose log is about . Each contributes .
Step 3. Add them: . This number, about , is the divergence of the posterior from the prior — the complexity charge.
Step 4. Suppose the sample has examples and we want confidence, so the confidence amount is the log of , about . The penalty is the square root of divided by , that is the square root of , about .
What this tells us: the average true error of a randomly drawn rule is at most its average training error plus about . Because the posterior stayed fairly close to the prior, the complexity charge was tiny next to the confidence amount, so the bound is dominated by the sample size, not by how the belief shifted.
Check your understanding Beginner
Formal definition Intermediate+
The setting is the agnostic learning setup of 45.07.05, now with the learner outputting a distribution over hypotheses rather than a single one. Fix a domain , a distribution on , a sample , a hypothesis class , and a loss . For write the true and empirical risks and .
Definition (prior and posterior). A prior is a probability measure on fixed before is drawn (independent of ). A posterior is any probability measure on , permitted to depend on arbitrarily. The names are borrowed from Bayesian inference, but need not be the Bayesian posterior of ; it is any data-dependent law [McAllester 1999].
Definition (Gibbs / randomised classifier and its risk). The Gibbs classifier associated with draws a fresh for each prediction. Its true and empirical risks are the -averages
PAC-Bayes bounds — the average true risk of the randomised classifier — in terms of and a divergence between and .
Definition (KL complexity term). The complexity is the relative entropy (Kullback-Leibler divergence) of 37.07.06,
defined to be when is not absolutely continuous with respect to . It replaces the cardinality, VC dimension, or Rademacher complexity of the worst-case theory by a quantity measuring only how far the chosen posterior departs from the prior.
Definition (small-kl). For the binary relative entropy is , the relative entropy of a against a . Maurer's form of the PAC-Bayes bound is stated in terms of ; Pinsker's inequality of 37.07.06 relaxes it to the square-root form.
Counterexamples to common slips Intermediate+
- "The posterior must be the Bayesian posterior of the prior." It need not be. PAC-Bayes holds for every posterior simultaneously, including ones produced by an optimiser, by a heuristic, or by the data-free choice . The freedom to pick after the bound is in hand is exactly what makes the bound usable: one optimises to minimise the right-hand side.
- "PAC-Bayes bounds the single returned classifier." It bounds the -averaged risk of the randomised (Gibbs) classifier. Bounding a single deterministic classifier requires a derandomisation step (a margin or majority-vote argument), which costs an extra factor and changes the object being bounded.
- "The prior encodes knowledge of ." The prior must be independent of the sample , but it may encode any data-free belief; a prior chosen with knowledge of (not of ) is legitimate and yields the sharpest data-distribution-dependent bounds. A prior that peeks at invalidates the bound, because the change-of-measure step needs to factorise.
Key theorem with proof Intermediate+
The signature result is the McAllester PAC-Bayes bound: the average true risk of the Gibbs classifier exceeds its average empirical risk by no more than a term governed by . The proof is a single change of measure — the Donsker-Varadhan variational inequality of 37.07.06 applied to a sub-Gaussian deviation, with the concentration controlled exactly as in 45.07.05 and 40.07.05.
Theorem (McAllester PAC-Bayes bound). Let be a prior on fixed before , and let take values in . For every , with probability at least over , simultaneously for all posteriors on ,
[McAllester 1999] [Shalev-Shwartz Ben-David 2014]
Proof. The workhorse is the change-of-measure inequality. For any measurable and any absolutely continuous with respect to , the Donsker-Varadhan duality of 37.07.06, , read as a one-sided bound at , gives
Apply with where and is fixed below. Then for every ,
after dividing by . Take the -expectation of the random variable inside the logarithm and bound it. Because is independent of , Fubini gives . For each fixed , is an average of independent terms with mean , so has a sub-Gaussian moment-generating function; the standard exponential-moment bound for such deviations gives for the choice , uniformly in . Hence .
Markov's inequality applied to the nonnegative random variable gives , since . So with probability , . On this event, for every at once,
and with one has for the leading constant absorbed below; tracking the constants of the sub-Gaussian step yields the cleaner . Jensen's inequality then gives , which is the stated bound.
Bridge. This theorem is the foundational reason the data-dependent capacity of 45.07.05 has a Bayesian-flavoured sibling: it shows the uniform deviation is controlled not by a complexity of the whole class but by the divergence of the single chosen posterior from the prior, and the bridge is the Donsker-Varadhan inequality of 37.07.06, which trades a -expectation one can concentrate for the -expectation one wants to bound at the additive price . This is exactly the change-of-measure move that lets a fixed-prior exponential-moment bound become a uniform-over-all-posteriors statement, the same way symmetrisation let the fixed-class bound of 45.07.05 become uniform over hypotheses. It generalises the finite-class union bound, whose term is recovered by taking uniform and a point mass, so . The central insight reappears throughout the chapter: generalisation is the concentration of an exponential moment read against an effective complexity, here the relative entropy. Putting these together, the Hoeffding/sub-Gaussian step is the concentration spine of 40.07.05 supplying the moment bound, and it builds toward the Catoni bound and the optimal Gibbs posterior, where minimising this very right-hand side over selects the exponential-weights distribution. The bridge is that is at once a complexity in a learning bound and the rate function of 37.07.06, and it appears again in the free-energy minimisation that closes the chapter.
Exercises Intermediate+
Advanced results Master
The McAllester bound is the entry point to four developments: the sharp binomial-kl form that is tightest at small risk, the Catoni convex-comparison bound with its fast rates, the optimal Gibbs posterior that minimises the bound, and the localisation and data-dependent-prior refinements that make the bounds non-vacuous in practice.
Theorem 1 (Maurer's binomial-kl bound). For a fixed prior and , with probability over , simultaneously for all ,
where is the binary relative entropy [McAllester 1999]. The proof replaces the squared-deviation potential by in the change-of-measure step, using Maurer's exact lemma in place of the Hoeffding sub-Gaussian bound. Inverting the binary-kl recovers the McAllester square-root bound through Pinsker, of 37.07.06, but is strictly tighter when is near or , where the binomial confidence interval is asymmetric — the regime of interpolating, low-empirical-risk learners.
Theorem 2 (Catoni's bound and fast rates). Fix . With probability , for all ,
a convex comparison through the function [Catoni 2007]. For small this reduces to McAllester's bound; for the optimal and under a Bernstein/Mammen-Tsybakov low-noise condition relating to its variance, the bound yields a fast rate rather than the worst-case . The temperature is the same inverse temperature that parametrises the Gibbs posterior; Catoni's monograph reads the entire PAC-Bayes theory as the thermodynamics of the free energy , with the entropy and the energy.
Theorem 3 (the optimal Gibbs posterior). For fixed , the posterior minimising the Catoni/McAllester right-hand side over all is the Gibbs posterior , the unique minimiser of the free-energy functional [Catoni 2007]. This is the Gibbs variational principle of 37.07.06 applied to the empirical-risk potential, and it is precisely the exponential-weights / multiplicative-weights distribution: is the continuous-domain analogue of the exponentiated-gradient iterate, and the free-energy minimisation is mirror descent with the negative-entropy mirror map. As , (no data influence); as , concentrates on the empirical risk minimisers. The plug-in PAC-Bayes bound at is the tightest achievable for that , and optimising as well balances energy against entropy.
Theorem 4 (data-dependent priors and non-vacuous bounds). The prior must be independent of , but it may depend on , or be learned from a held-out split of the data; choosing close to the region where will land shrinks and tightens the bound [Catoni 2007]. For stochastic neural networks, optimising a Gaussian posterior against a Gaussian prior to directly minimise the PAC-Bayes right-hand side produces numerically non-vacuous generalization certificates — bounds strictly below the worst-case value — even for over-parametrised networks, because measures a norm-like distance in weight space rather than the parameter count [McAllester 1999]. This is the route by which PAC-Bayes, alone among the classical bounds of this chapter, gives non-vacuous numbers for deep networks: the complexity is the description length of the learned weights under the prior code, not the dimension of the weight space.
Synthesis. The foundational reason PAC-Bayes exists as a separate pillar is that one quantity — the relative entropy of the chosen posterior from the prior — governs the generalisation gap, the optimal posterior, and, through temperature, the rate, and every result here is that single quantity read through a different operation. This is exactly the meeting of the change-of-measure inequality of 37.07.06 and the concentration of 40.07.05 that also powered 45.07.05: Donsker-Varadhan produces the term, Hoeffding (or Maurer) bounds the prior-averaged exponential moment, and putting these together the worst-case capacity of the distribution-free theory becomes the posterior-adapted , which recovers the finite-class bound through a point-mass posterior as its special case and improves on it whenever the posterior stays near a well-chosen prior.
The Maurer and Catoni bounds are dual readings of the same change of measure — squared deviation versus binary-kl versus convex — and the Gibbs posterior is the central insight that links the bound to optimisation: minimising the PAC-Bayes right-hand side is the free-energy minimisation of 37.07.06, which is exactly mirror descent with the entropic mirror map, so the optimal learner and the optimal certificate are one object. The bridge upward at every level is the same: the cardinality generalises to , the union bound generalises to the change of measure, and the high-probability upgrade is always Markov on a prior-averaged exponential moment whose concentration is the spine of 40.07.05; PAC-Bayes is therefore the Occam/MDL principle made quantitative, with the code length that a shorter description of the data buys back.
Full proof set Master
Proposition 1 (change-of-measure / Donsker-Varadhan inequality). Let be probability measures on with , and measurable with . Then , with equality iff .
Proof. Let and let be the tilted measure with . Then
Since by Gibbs' inequality of 37.07.06, , which rearranges to the claim, with equality iff , i.e. , i.e. .
Proposition 2 (prior-averaged exponential moment). Fix a prior independent of and . With , .
Proof. By Fubini (the integrand is nonnegative and ), . Fix . By Pinsker's inequality of 37.07.06, , so . Maurer's lemma states that for a sum of independent variables with mean , (the binomial case being extremal). Hence for every , and averaging over preserves the bound.
Proposition 3 (McAllester PAC-Bayes bound). With as above and , with probability over , for all , .
Proof. Let . By Proposition 2, , so Markov gives . Condition on the event , of probability . Apply Proposition 1 with : for every ,
Dividing by , . By Jensen, , and the deviation is bounded above by its absolute value, so taking square roots gives the claim. The bound is uniform in because Proposition 1 and the event hold for all at once.
Proposition 4 (Gibbs posterior minimises the free energy). Fix and define . Then , attained uniquely at .
Proof. Apply Proposition 1's equality case with : for every , , i.e. , i.e. , with equality iff . The tilted measure achieves equality, and uniqueness follows from the strict positivity of for , as in Proposition 1.
Proposition 5 (majority-vote derandomisation). For binary under – loss and , .
Proof. For any , if then the weighted vote favoured the wrong label, so ; thus pointwise (the inequality is automatic when , the left side being ). Taking and applying Fubini to exchange the - and -expectations gives .
Connections Master
This unit closes the statistical-learning-theory chapter alongside the data-dependent bounds of 45.07.05. Where Rademacher complexity measures the capacity of the whole loss class through its average alignment with random signs, PAC-Bayes measures only the divergence of a single chosen posterior from a fixed prior; the two are complementary readings of the same generalisation problem, and the finite-class bound that Massart's lemma delivers in 45.07.05 is recovered here by a point-mass posterior against a uniform prior, exhibiting both as refinements of the union bound of 45.07.04.
The proof engine is the Donsker-Varadhan variational formula and the Gibbs variational principle of 37.07.06: the change-of-measure inequality is exactly the one-sided reading of that unit's duality, and the optimal Gibbs posterior is its tilted-measure maximiser specialised to the empirical-risk potential. The relative entropy that is a large-deviations rate function in 37.07.06 is the learning-theoretic complexity here.
The high-probability upgrade rests on the concentration spine of 40.07.05: the prior-averaged exponential moment is controlled by the Hoeffding/Maurer sub-Gaussian bound established there, the same per-hypothesis exponential-moment tool that fed the McDiarmid step of 45.07.05, with Markov's inequality replacing the union bound. The bounded-differences machinery of 40.07.05 is what makes the single-sample PAC-Bayes certificate computable.
The Gibbs/exponential-weights posterior links PAC-Bayes to optimisation: minimising the bound is a free-energy minimisation that coincides with mirror descent under the negative-entropy mirror map, the continuous-domain analogue of the multiplicative-weights and exponentiated-gradient updates of 44.06.05, so the optimal certificate and the optimal stochastic learner are the same object — the thermodynamic reading Catoni develops, and the formal bridge from generalisation theory to the convex-optimisation chapter.
Historical & philosophical context Master
The PAC-Bayesian theorem was introduced by David McAllester in 1999, first at the Conference on Computational Learning Theory and then in Machine Learning, giving the bound on the Gibbs classifier's risk in terms of the relative entropy between a data-dependent posterior and a data-free prior, and identifying the bound's uniformity over all posteriors as the feature that lets the posterior be optimised after the fact [McAllester 1999]. The framework synthesised the PAC tradition of Valiant and Vapnik-Chervonenkis with the Bayesian and minimum-description-length ideas of Rissanen and the model-averaging bounds of Shawe-Taylor and Williamson, recasting Occam's razor as the quantitative statement that the complexity charge is the code length of the posterior under the prior code.
The convex-analytic and thermodynamic development is due to Olivier Catoni, whose 2007 IMS monograph established the tightest constants, the convex-comparison bound, the localisation technique, and the reading of the whole theory as the thermodynamics of statistical learning, with the Gibbs posterior as the free-energy minimiser and an inverse temperature [Catoni 2007]. The sharp binomial-kl form and its clean proof through an exact exponential-moment lemma are due to Andreas Maurer (2004). The assembly of the framework into a textbook theorem with the Donsker-Varadhan change-of-measure proof, the form bounding the Gibbs classifier through , is the treatment of Shalev-Shwartz and Ben-David (2014) [Shalev-Shwartz Ben-David 2014]. The framework returned to prominence when Dziugaite and Roy (2017) used it to compute the first non-vacuous generalization bounds for stochastic deep neural networks by directly optimising the posterior.
Bibliography Master
@inproceedings{mcallester1999colt,
author = {McAllester, David A.},
title = {{PAC}-{Bayesian} model averaging},
booktitle = {Proceedings of the Twelfth Annual Conference on Computational Learning Theory (COLT)},
pages = {164--170},
year = {1999}
}
@article{mcallester1999ml,
author = {McAllester, David A.},
title = {Some {PAC}-{Bayesian} theorems},
journal = {Machine Learning},
volume = {37},
number = {3},
pages = {355--363},
year = {1999}
}
@book{catoni2007,
author = {Catoni, Olivier},
title = {{PAC}-{Bayesian} Supervised Classification: The Thermodynamics of Statistical Learning},
series = {IMS Lecture Notes - Monograph Series},
volume = {56},
publisher = {Institute of Mathematical Statistics},
year = {2007}
}
@inproceedings{maurer2004,
author = {Maurer, Andreas},
title = {A note on the {PAC} {Bayesian} theorem},
booktitle = {arXiv:cs/0411099},
year = {2004}
}
@book{shalevshwartzbendavid2014,
author = {Shalev-Shwartz, Shai and Ben-David, Shai},
title = {Understanding Machine Learning: From Theory to Algorithms},
publisher = {Cambridge University Press},
year = {2014}
}
@inproceedings{dziugaiteroy2017,
author = {Dziugaite, Gintare Karolina and Roy, Daniel M.},
title = {Computing nonvacuous generalization bounds for deep (stochastic) neural networks with many more parameters than training data},
booktitle = {Proceedings of the Thirty-Third Conference on Uncertainty in Artificial Intelligence (UAI)},
year = {2017}
}
@article{germain2016,
author = {Germain, Pascal and Bach, Francis and Lacoste, Alexandre and Lacoste-Julien, Simon},
title = {{PAC}-{Bayesian} theory meets {Bayesian} inference},
journal = {Advances in Neural Information Processing Systems},
volume = {29},
year = {2016}
}