PAC-Bayes Bounds
Generalisation from a prior to a posterior: the test error of a randomised predictor exceeds its train error by about the square root of KL over $n$. Flat minima with small KL generalise.
Why Does This Exist?
Uniform bounds pay for the whole class even when the learned model sits in a flat, simple region. What you want is a bound that rewards the actual posterior: if the final weights stay near the prior or inside a flat valley where perturbations barely change predictions, the guarantee should tighten. Classical VC cannot see the learned weights at all.
PAC-Bayes does. Fix a prior before seeing data, learn a posterior after, and bound the average test error under by the average train error plus , where is KL divergence (information distance from prior to posterior) and is failure chance. Small KL means the data moved beliefs little or the valley is wide, and the bound nearly matches training error.
Prerequisite in one paragraph. You need KL divergence , the extra nats for encoding draws with 's code, and the idea of a randomised predictor that draws weights fresh per prediction. Background is in Kullback-Leibler divergence and confidence intervals.
Think of It Like This
A hiker reporting back to base camp
Base camp is the prior: where you guessed the summit was before climbing. The hiker's final camp is the posterior. If the hiker moved only 50 metres to a broad plateau, base camp trusts the report cheaply: the message describing the move is short. If they traversed 500 metres of ridge, the message is long and trust costs more.
KL is the message length. PAC-Bayes charges generalisation by that length over . Flat plateaus let the hiker wander without lengthening the message much, because a wide posterior near the prior covers the wander.
Where the analogy stops: hikers choose paths adaptively while the prior must be fixed before data. Data-dependent priors need differential-privacy or split-data fixes, which the camp story hides.
How It Actually Works
Fix prior over predictors before data. After samples pick any posterior . With chance at least over the sample, every satisfies , where is test error, train error and the KL. The bound holds uniformly over posteriors, so optimising after seeing data is legal: the KL prices the optimisation.
For Gaussians and in dimensions, . Wide posteriors (large ) tolerate large moves at fixed KL, which is the flat-minima mechanism: flat valleys admit wide with small train error and modest KL.
Worked example
Take , , train error . Posterior A stays near the prior with . Then , numerator , denominator , ratio , root . Refined constants in the diagram report with the common versus form plus a union penalty; either way test error below about .
Posterior B drifts far with : numerator , ratio , root , diagram with looser constants. Same train error, triple the guarantee price. The lesson is quantitative: every extra nats of KL at costs about in the bound.
Watch Out For
Tuning the prior on the test data
The theorem fixes before the sample. Fitting the prior mean on the full training set and quoting the bound reuses data: the KL understates the true move and the guarantee is invalid. This is the most common PAC-Bayes error in practice.
Fix: split data, use a data-free prior, or pay the differential-privacy correction for data-dependent priors. State which you did.
Reporting the randomised error as the deterministic error
The bound covers , the average over posterior draws, not the single mean predictor's error. A wide posterior can have small average error while its centre errs more, or vice versa. Quoting the bound next to deterministic test accuracy compares different quantities.
Fix: derandomise with a separate step (margin or de-randomisation bound) or evaluate the randomised predictor by sampling.
The Quick Version
- PAC-Bayes bounds posterior test error by train error plus .
- KL 50 at 2000 samples adds about 0.19; KL 500 adds about 0.60 on the same train error.
- Flat minima help because wide posteriors keep train error low at modest KL.
- The prior must predate the data; tuning it on train silently voids the bound.
- The guarantee covers randomised predictors, not the deterministic centre, without extra steps.