Why Posterior Approximation Needs Its Own Error Term
A PAC-Bayes guarantee applies to a distribution over predictors, not only to a single predictor. In practice, the distribution a method can compute may be an approximation to a target posterior: for example, it may come from a numerical procedure or a restricted representation. A guarantee for the target posterior does not automatically become a guarantee for the approximation. The difference in their risks must be controlled, and the PAC-Bayes complexity term may also change.
This tutorial separates these effects. We first give a uniform PAC-Bayes bound for bounded losses, then compare an approximate posterior with a target posterior using total variation. A KL bound can control that discrepancy, but it is important to use the correct direction of KL and not to assume that KL divergence satisfies a triangle inequality.
Setup and a Uniform PAC-Bayes Bound
Let \(\mathcal H\) be a finite hypothesis class, let \(P\) be a prior distribution on \(\mathcal H\) fixed independently of the sample, and let \(Z_1,\ldots,Z_n\) be independent observations from a distribution \(D\). For each \(h\in\mathcal H\), assume the loss \(\ell(h,z)\) is measurable and lies in \([0,1]\). Define the population and empirical risks by
For any distribution \(Q\) on \(\mathcal H\), write \(R(Q)=E_{h\sim Q}[R(h)]\) and \(\widehat R_S(Q)=E_{h\sim Q}[\widehat R_S(h)]\). The KL divergence is \(\operatorname{KL}(Q\|P)=\sum_h Q(h)\log(Q(h)/P(h))\), with zero-mass terms omitted; it is infinite if \(Q\) assigns positive mass where \(P\) is zero.
The fixed \(\lambda\) matters: the same high-probability event works for every \(Q\), including posteriors chosen after observing the sample. Choosing \(\lambda\) separately from the observed KL of each posterior requires an additional argument. If a family of posteriors is known in advance to satisfy \(\operatorname{KL}(Q\|P)\leq K\), one may choose \(\lambda=\sqrt{8n(K+\log(1/\delta))}\). The resulting bound holds simultaneously over that family, with the two penalty terms summing to \(\sqrt{(K+\log(1/\delta))/(2n)}\).
Proof of the Uniform Bound
For a fixed \(h\), Hoeffding's lemma applied to the independent bounded losses gives
Indeed, \(R(h)-\widehat R_S(h)\) is the average of \(n\) independent centered variables, each with range length at most one; their moment-generating-function bounds multiply. Define \(Z_S=\sum_h P(h)\exp\{\lambda(R(h)-\widehat R_S(h))\}\). Averaging the preceding inequality over \(P\) gives \(E_S[Z_S]\leq \exp(\lambda^2/(8n))\). Markov's inequality therefore implies that, with probability at least \(1-\delta\),
On this event, take any \(Q\) with finite KL divergence. On the support of \(Q\), Jensen's inequality gives the change-of-measure inequality
The first inequality holds because the sum over the support of \(Q\) is only part of the full sum over \(P\); it does not require \(Q\) and \(P\) to have identical supports. Apply this inequality with \(\phi(h)=\lambda(R(h)-\widehat R_S(h))\). Combining it with the bound on \(\log Z_S\), then dividing by \(\lambda\), proves the theorem. The event was defined using \(Z_S\), independently of \(Q\), so the conclusion holds simultaneously for every such \(Q\). \(\square\)
Comparing an Approximate Posterior with Its Target
Let \(\rho\) denote a target posterior and \(Q\) an approximate posterior. Their total variation distance is
For any function \(g:\mathcal H\to[0,1]\), its expectations under these distributions differ by at most this distance. In particular, this holds both for the population risk \(R(h)\) and for the sample-specific empirical risk \(\widehat R_S(h)\).
To see the first inequality, apply the PAC-Bayes theorem to \(\rho\), then use \(R(Q)\leq R(\rho)+\operatorname{TV}(Q,\rho)\). For the second, also use \(\widehat R_S(\rho)\leq\widehat R_S(Q)+\operatorname{TV}(Q,\rho)\). Both applications are permitted even when the posteriors depend on the sample, because the event is uniform over distributions on \(\mathcal H\).
Controlling Risk Discrepancy with KL Divergence
For finite distributions, Pinsker's inequality states that
Here the direction is \(Q\|\rho\): a small \(\operatorname{KL}(Q\|\rho)\) controls the change from the target to the approximation. If \(Q\) puts mass outside the support of \(\rho\), this KL divergence is infinite and gives no such control.
For completeness, let \(A=\{h:Q(h)>\rho(h)\}\). Then \(\operatorname{TV}(Q,\rho)=Q(A)-\rho(A)\). Grouping the terms of the KL sum over \(A\) and its complement gives
This grouping inequality follows by applying Jensen's inequality to the terms in each group; boundary cases follow by continuity or give infinite KL. For fixed \(r\in(0,1)\), the binary expression as a function of \(q\) has value and first derivative zero at \(q=r\), and second derivative \(1/[q(1-q)]\geq4\). Integrating this second-derivative bound between \(r\) and \(q\) yields a lower bound \(2(q-r)^2\). Thus \(\operatorname{KL}(Q\|\rho)\geq2\operatorname{TV}(Q,\rho)^2\), proving the stated inequality.
Substituting Pinsker's inequality into the comparison theorem turns an approximation guarantee in KL into an explicit risk penalty. In the bound using the approximate empirical risk, that penalty is at most \(\sqrt{2\operatorname{KL}(Q\|\rho)}\). Using the target empirical risk instead costs only \(\sqrt{\operatorname{KL}(Q\|\rho)/2}\).
Worked Example: Computing a Posterior's Prior Complexity
Consider a two-hypothesis class with uniform prior \(P=(0.5,0.5)\), and let \(Q=(0.7,0.3)\). Its KL complexity is
For \(n=100\), \(\delta=0.05\), and fixed \(\lambda=20\), the theorem's excess-risk penalty is
Thus, on the theorem's event, \(R(Q)\leq\widehat R_S(Q)+0.17890\). This calculation concerns the PAC-Bayes complexity relative to the prior; it is distinct from the extra error incurred when approximating some other target posterior.
Worked Example: Translating Approximation KL into Risk Error
Let the target posterior be \(\rho=(0.8,0.2)\) and the approximation be \(Q=(0.7,0.3)\) on two hypotheses. Their total variation distance is
The directed KL divergence is
Pinsker's bound gives \(\operatorname{TV}(Q,\rho)\leq\sqrt{0.028168/2}\approx0.1187\), which is valid but looser than the exact value \(0.1\). If the two hypotheses have empirical risks \(0.10\) and \(0.30\), then \(\widehat R_S(\rho)=0.8(0.10)+0.2(0.30)=0.14\), while \(\widehat R_S(Q)=0.7(0.10)+0.3(0.30)=0.16\). The observed difference \(0.02\) is below the general bound \(0.1\), as it must be for risks in \([0,1]\).
Worked Example: A Finite-Class Approximate-Posterior Guarantee
Take three hypotheses with uniform prior \(P=(1/3,1/3,1/3)\), target posterior \(\rho=(0.6,0.3,0.1)\), and approximation \(Q=(0.5,0.4,0.1)\). Suppose their empirical risks are \(0.05,0.20,0.60\), respectively. Then
The target's prior complexity and the posterior discrepancy are
Set \(n=500\), \(\delta=0.05\), and \(\lambda=40\). The common PAC-Bayes penalty is
The target-risk comparison therefore gives \(R(Q)\leq0.15+0.1+0.08991=0.33991\). If the bound is written using the approximate empirical risk instead, it gives \(R(Q)\leq0.165+0.2+0.08991=0.45491\). Both hold on the same event of probability at least \(0.95\); the second pays twice for the empirical-risk discrepancy because it changes from the target empirical risk to the approximate one as well as from target to approximate population risk.
When Approximation Also Changes Complexity
The comparison just proved uses the target's KL complexity and pays explicitly for risk discrepancy. One can instead apply the PAC-Bayes theorem directly to \(Q\), but then the complexity is \(\operatorname{KL}(Q\|P)\). These two complexities cannot generally be interchanged using a triangle inequality: KL is not a metric.
A useful exact identity, when \(Q\ll\rho\ll P\), is
It follows by splitting \(\log(Q/P)=\log(Q/\rho)+\log(\rho/P)\) on the support of \(Q\). If \(\log(\rho(h)/P(h))\leq M\) everywhere that \(Q(h)>0\), then \(\operatorname{KL}(Q\|P)\leq\operatorname{KL}(Q\|\rho)+M\), and this can be substituted into the direct PAC-Bayes bound for \(Q\). Without a condition of this kind, a small KL divergence from \(Q\) to \(\rho\) alone does not ensure that \(Q\)'s prior complexity is close to \(\rho\)'s.
Common Pitfall
A common mistake is to claim that a small \(\operatorname{KL}(Q\|\rho)\) makes the PAC-Bayes bound for \(Q\) nearly identical to the bound for \(\rho\). That conclusion confuses two different quantities: the risk discrepancy, controlled by total variation, and the prior complexity, which is \(\operatorname{KL}(Q\|P)\). The correction is to state which route is being used. Either compare risks and retain the target complexity, or use \(Q\)'s complexity and justify its relationship to the target's. Also, when replacing the target empirical risk with the approximate empirical risk, include the second total-variation term.
Check Your Understanding
Use the definitions and bounds above to answer these questions.
- Why does the uniform PAC-Bayes event permit the target posterior to depend on the observed sample?
- For losses in \([0,1]\), what bound controls the difference between the empirical risks under \(Q\) and \(\rho\)?
- Which direction of KL divergence is used with Pinsker's inequality to control \(\operatorname{TV}(Q,\rho)\), and what happens if \(Q\) assigns mass outside the support of \(\rho\)?
- Why does replacing \(\widehat R_S(\rho)\) by \(\widehat R_S(Q)\) add a second total-variation term?
- What additional condition would let you bound \(\operatorname{KL}(Q\|P)\) using \(\operatorname{KL}(Q\|\rho)\) and the target-to-prior density ratio?