Why Compare Risks in Binary Relative Entropy?
A high-probability PAC-Bayes bound must account for two sources of uncertainty: the data used to estimate risk and the posterior distribution over predictors, which may itself depend on those data. A bound written in binary relative entropy gives a particularly direct comparison between empirical and population Gibbs risk. It also yields an upper confidence limit by solving a one-dimensional inequality.
Throughout, let \(Z_1,\ldots,Z_n\) be independent and identically distributed observations from a distribution \(D\). Let \(\mathcal H\) be a measurable predictor space, and let \(\ell(h,z)\in[0,1]\) be a measurable loss. The prior \(\pi\) is a probability distribution on \(\mathcal H\) fixed independently of the sample. A posterior \(\rho\) is any probability distribution on \(\mathcal H\), including one selected after observing the sample.
Write \(\operatorname{KL}(\rho\|\pi)\) for the relative entropy between distributions on predictors. It is finite only when \(\rho\) is absolutely continuous with respect to \(\pi\), with the usual integral definition. The inequality below uses a convenient finite-sample constant \(n+1\). Sharper constants are possible, but the \(n+1\) version follows from a short method-of-types argument.
A Bounded-Loss Exponential-Moment Bound
The first step controls, for a fixed predictor, the exponential of the binary relative entropy between its empirical and population risks. The argument also explains why the result applies to losses anywhere in \([0,1]\), not just zero-one losses.
Proof. First suppose \(0<\mu<1\), and define \(f(x)=\exp\{n\operatorname{kl}(x\|\mu)\}\) on \([0,1]\). Binary relative entropy is convex in its first argument and nonnegative. Since the exponential is convex and increasing, \(f\) is convex. For any random variable \(X\in[0,1]\), convexity gives \(f(X)\le (1-X)f(0)+Xf(1)\). Thus its expected value is no greater than the expected value obtained by replacing \(X\) with a Bernoulli variable having the same mean.
Apply this replacement one coordinate at a time to \(f(n^{-1}\sum_i X_i)\). With all other coordinates fixed, this is a convex function of the remaining coordinate, so each replacement can only increase the expectation. The resulting variables are independent Bernoulli variables with success probability \(\mu\). If \(K\) is their sum, then
At \(k=0\) or \(k=n\), powers with exponent zero are interpreted as one. Each summand simplifies to \({n\choose k}(k/n)^k(1-k/n)^{n-k}\). This is the probability of obtaining exactly \(k\) successes in \(n\) Bernoulli trials with success probability \(k/n\), so it is at most one. There are \(n+1\) summands, proving the bound. If \(\mu=0\) or \(\mu=1\), the variables equal their mean almost surely, and the expectation is one. \(\square\)
The PAC-Bayes-KL Inequality
For a fixed predictor \(h\), apply the lemma to \(X_i=\ell(h,Z_i)\), whose mean is \(R(h)=E_Z[\ell(h,Z)]\). Integrating the resulting exponential bound over the prior gives an event that can be used for every posterior, even a posterior selected using the sample.
Proof. For each sample \(S\), put \(g_S(h)=n\operatorname{kl}(\hat R_S(h)\|R(h))\), where \(\hat R_S(h)=n^{-1}\sum_i\ell(h,Z_i)\). The lemma and integration over \(h\sim\pi\) imply \(E_S E_{h\sim\pi}[\exp\{g_S(h)\}]\le n+1\). Markov’s inequality therefore gives, with probability at least \(1-\delta\), \(E_{h\sim\pi}[\exp\{g_S(h)\}]\le(n+1)/\delta\). Fix any sample in this event.
For any \(\rho\ll\pi\), the change-of-measure inequality gives \(E_\rho[g_S]\le\operatorname{KL}(\rho\|\pi)+\log E_\pi[\exp\{g_S\}]\). This inequality follows by applying Jensen’s inequality to the logarithm under \(\rho\): \(E_\rho[g_S]-\operatorname{KL}(\rho\|\pi) =E_\rho[\log(\exp(g_S)\,d\pi/d\rho)] \le\log E_\pi[\exp(g_S)]\). The displayed expectation is finite on the chosen event.
Finally, binary relative entropy is jointly convex. To see this, use convexity of \(\phi(t)=t\log t\): for nonnegative measurable \(a,b\), \(E[b\phi(a/b)]\ge E[b]\phi(E[a]/E[b])\), with the zero cases understood by continuity. Applying this once to \(a\) and \(b\), and once to \(1-a\) and \(1-b\), proves \(\operatorname{kl}(E_\rho a\|E_\rho b)\le E_\rho[\operatorname{kl}(a\|b)]\). Take \(a=\hat R_S(h)\) and \(b=R(h)\). Combining joint convexity with the change-of-measure inequality and the event bound yields \[ n\operatorname{kl}\bigl(\hat R_S(\rho)\|R(\rho)\bigr) \le E_\rho[g_S] \le\operatorname{KL}(\rho\|\pi)+\log((n+1)/\delta). \] The event did not depend on \(\rho\), so the conclusion holds simultaneously for every posterior. \(\square\)
Turning the Inequality Into an Upper Limit
On the theorem’s event, set \(q=\hat R_S(\rho)\), \(p=R(\rho)\), and \(c=[\operatorname{KL}(\rho\|\pi)+\log((n+1)/\delta)]/n\). The theorem says \(\operatorname{kl}(q\|p)\le c\). For fixed \(q<1\), the function \(u\mapsto\operatorname{kl}(q\|u)\) is increasing for \(u>q\), since its derivative is \((u-q)/(u(1-u))\). Thus the exact upper endpoint is determined by a single binary-entropy equation.
For \(q<1\), the defining root exists and is unique: the function is continuous from zero at \(u=q\), strictly increasing for \(u>q\), and tends to infinity as \(u\) tends to one. The exact root generally has no elementary closed form, but it is readily computed by bisection. A simple algebraic upper limit follows from Pinsker’s inequality for Bernoulli distributions: \(\operatorname{kl}(q\|p)\ge2(q-p)^2\). For completeness, with \(p\) fixed, the second derivative of \(\operatorname{kl}(q\|p)\) in \(q\) is \(1/[q(1-q)]\ge4\). Its value and first derivative at \(q=p\) are zero; integrating the second-derivative bound on either side of \(p\) gives the stated inequality. Consequently,
The root gives the sharper limit; the square-root expression is easier to evaluate and can be more conservative. Both limits inherit the theorem’s probability guarantee and hold for every posterior on the same event.
Worked Example: Correcting the Complexity Arithmetic
Suppose \(n=50\), \(\delta=0.10\), a chosen posterior has \(\operatorname{KL}(\rho\|\pi)=0.130812\), and its empirical Gibbs risk is \(q=0.20\). Calculate the PAC-Bayes-KL threshold and the resulting population-risk limits.
First, \((n+1)/\delta=51/0.10=510\), and \(\log(510)\approx6.234411\). Therefore \[ c=\frac{0.130812+\log(510)}{50} =\frac{0.130812+6.234411}{50} =\frac{6.365223}{50} \approx0.127304. \] The exact upper endpoint solves \(\operatorname{kl}(0.20\|u)=0.127304\); numerical inversion gives \(U_{\mathrm{kl}}(0.20,c)\approx0.43965\). Hence the theorem gives \(R(\rho)\lesssim0.43965\) on its 90% event.
For the simpler algebraic limit, \(\sqrt{c/2}=\sqrt{0.127304/2}\approx0.25229\). Thus \(R(\rho)\le\min\{1,0.20+0.25229\}=0.45229\). This is a valid but looser upper limit than the binary-KL root.
Worked Example: Inverting at Zero Empirical Risk
Suppose \(n=20\), \(\delta=0.05\), and the posterior equals the prior, so \(\operatorname{KL}(\rho\|\pi)=0\). If the empirical Gibbs risk is zero, find the exact upper limit.
Here \(c=\log((20+1)/0.05)/20=\log(420)/20\approx6.040255/20=0.302013\). Since \(\operatorname{kl}(0\|u)=-\log(1-u)\), the root equation is \(-\log(1-u)=c\). Solving gives \(u=1-\exp(-c)=1-420^{-1/20}\approx1-0.7394=0.2606\). Thus zero empirical risk does not imply zero population risk: the bound gives an upper limit of about \(0.261\) at confidence level 95%.
Worked Example: Checking a Posterior-Averaged Risk Pair
Consider two predictors with posterior probabilities \(0.9\) and \(0.1\). Their empirical risks are \(0.10\) and \(0.50\), and their population risks are \(0.20\) and \(0.60\). Compute the Gibbs risks and check the KL comparison for \(n=100\), \(\delta=0.05\), and a prior assigning probability \(0.5\) to each predictor.
The empirical Gibbs risk is \(q=0.9(0.10)+0.1(0.50)=0.14\). The population Gibbs risk is \(p=0.9(0.20)+0.1(0.60)=0.24\). The posterior complexity is \[ \operatorname{KL}(\rho\|\pi) =0.9\log(1.8)+0.1\log(0.2) \approx0.529008-0.160944=0.368064. \] Also, \(\log((101)/0.05)=\log(2020)\approx7.610853\), so \(c=(0.368064+7.610853)/100\approx0.079789\).
The observed binary relative entropy is \[ \operatorname{kl}(0.14\|0.24) =0.14\log(0.14/0.24)+0.86\log(0.86/0.76) \approx-0.075459+0.106307=0.030848. \] This is below \(c\approx0.079789\). The risk pair is therefore consistent with the theorem’s inequality; it does not, by itself, establish that the theorem’s high-probability event occurred for a particular random sample.
Interpretation and a Common Pitfall
The complexity term penalizes posteriors that move far from the prior, while the logarithmic confidence term decreases as the requested failure probability increases. The binary relative-entropy form is useful because it respects the bounded risk scale: the inequality is not merely a generic additive deviation statement. Inverting it can give a notably tighter upper limit than the Pinsker-based square-root expression, especially near the endpoints.
- Pitfall: choosing the prior after seeing the sample. The proof begins by bounding the prior-averaged exponential moment over repeated samples. If the prior is selected using the same data without an appropriate correction, that expectation argument does not justify the stated guarantee. The required correction is to use a prior fixed independently of the sample, or to establish a valid procedure for handling data-dependent priors.
- Pitfall: treating a small empirical risk as a population guarantee on its own. The conclusion also depends on sample size, confidence level, and posterior complexity. A data-dependent posterior is allowed, but its divergence from the prior appears explicitly in the bound.
- Pitfall: reversing the inverse. The upper limit is found by increasing the second argument \(u\) of \(\operatorname{kl}(q\|u)\) from \(q\) until the divergence reaches \(c\). It is not obtained by solving for the first argument while holding the population risk fixed.
Check Your Understanding
Use the definitions and results above to answer these questions.
- Why does the PAC-Bayes-KL theorem permit a posterior chosen after observing the data, while still requiring the prior to be fixed independently of the sample?
- For a fixed empirical risk \(q<1\), why is the upper endpoint found by solving \(\operatorname{kl}(q\|u)=c\) with \(u\ge q\)?
- If \(q=0\), derive the exact upper endpoint in terms of \(c\).
- What does the term \(\operatorname{KL}(\rho\|\pi)\) contribute to the upper confidence limit?
- Why can the square-root limit be valid even when it is larger than the exact binary-KL root?