Tutorials › Statistical Learning (Graduate) › Fast PAC-Bayes Rates Under Bernstein Conditions

PAC-Bayesian Generalization · Tutorial 360 of 989

Fast PAC-Bayes Rates Under Bernstein Conditions

Learn how a Bernstein variance condition converts a PAC-Bayes generalization bound into a fast rate, and how the temperature controls its constants.

Advanced 11 min read

What You'll Learn

  • Define excess risk and the Bernstein condition for excess loss.
  • Derive the exponential moment bound that drives the fast-rate argument.
  • Apply a change-of-measure inequality to obtain a uniform PAC-Bayes guarantee.
  • Check the required temperature range and positivity condition.
  • Choose a temperature that gives dependence proportional to prior divergence divided by sample size.
  • Identify why signed excess loss cannot be treated as an ordinary loss in the proof.

Why a Variance Condition Can Give a Faster Rate

A usual PAC-Bayes generalization bound often balances empirical performance against a complexity penalty whose scale is proportional to \(1/\sqrt{n}\). In some problems, however, predictors that are already close to optimal also have less variable excess loss. When the variance of excess loss is bounded by a constant times its mean, this relationship can support a faster rate: the complexity contribution can scale as \(1/n\), rather than \(1/\sqrt{n}\).

The key is to compare each predictor with a fixed risk minimizer. Its excess loss is signed: it can be negative on some observations even though its expected value is nonnegative. The Bernstein condition controls the variance of this signed quantity, and an exponential-moment argument turns that control into a PAC-Bayes bound.

Definition: Let \(Z\) be an observation, let \(h\) be a predictor, and let \(\ell_h(Z)\in[0,1]\) be its loss. Write \(R(h)=E[\ell_h(Z)]\). Suppose a fixed predictor \(h^*\) minimizes \(R(h)\) over the predictor class. Define the excess loss \(X_h(Z)=\ell_h(Z)-\ell_{h^*}(Z)\), the excess risk \(r(h)=R(h)-R(h^*)=E[X_h(Z)]\), and, for an i.i.d. sample \(Z_1,\ldots,Z_n\), the empirical excess risk \(\hat r(h)=n^{-1}\sum_{i=1}^n X_h(Z_i)\). A Bernstein condition with constant \(B\) is the requirement \(\operatorname{Var}(X_h(Z))\le B r(h)\) for every predictor under consideration.

Because \(h^*\) is a risk minimizer, \(r(h)\ge0\). Since the losses lie in \([0,1]\), \(X_h(Z)\in[-1,1]\) and \(r(h)\in[0,1]\). The condition is meaningful even when the excess loss sometimes takes negative values: it controls its variance, not its pointwise sign.

Worked Example: Checking a Bernstein Condition

Suppose \(h^*\) has loss zero on every observation, while a second predictor \(h\) has loss one with probability \(p\) and zero with probability \(1-p\), where \(0\le p\le1\). Then \(X_h\) is Bernoulli with success probability \(p\).

Its mean and variance are \(\displaystyle r(h)=E[X_h]=p\) and \(\displaystyle \operatorname{Var}(X_h)=p(1-p)\). Since \(1-p\le1\), we have \(\displaystyle \operatorname{Var}(X_h)=p(1-p)\le p=r(h)\). Thus the Bernstein condition holds with \(B=1\). When \(p=0\), both sides are zero, so the condition still holds. This example shows the relevant scaling: as the predictor's excess risk decreases, its excess-loss variance decreases at least as quickly.

The Exponential-Moment Step

We first establish the concentration inequality used in the PAC-Bayes argument. The proof is included to make clear why the temperature has an upper limit and where the constant \(2/3\) comes from.

Lemma: If \(Y\) is a mean-zero random variable with \(|Y|\le b\) almost surely, then, for \(t\ge0\) with \(tb<3\), \(\displaystyle E[e^{tY}]\le \exp\!\left(\frac{t^2\operatorname{Var}(Y)}{2(1-tb/3)}\right)\).

Proof. Expand the exponential in its power series. The linear term vanishes because \(E[Y]=0\). For every integer \(k\ge2\), \(\displaystyle |E[Y^k]|\le E[|Y|^k]\le b^{k-2}E[Y^2]\). Also, \(k!\ge 2\cdot3^{k-2}\) for \(k\ge2\): equality holds for \(k=2,3\), and multiplying by \(k+1\ge3\) preserves the inequality at each subsequent step. Thus, with \(0\le tb<3\),

$$ \begin{aligned} E[e^{tY}] &=1+\sum_{k=2}^{\infty}\frac{t^k E[Y^k]}{k!}\\ &\le 1+\frac{t^2 E[Y^2]}{2} \sum_{j=0}^{\infty}\left(\frac{tb}{3}\right)^j\\ &=1+\frac{t^2\operatorname{Var}(Y)}{2(1-tb/3)}\\ &\le \exp\!\left(\frac{t^2\operatorname{Var}(Y)}{2(1-tb/3)}\right). \end{aligned} $$

The last inequality is \(1+u\le e^u\) for \(u\ge0\). The power-series operations are valid because \(Y\) is bounded, so the exponential series is absolutely integrable. \(\square\)

For a fixed predictor \(h\), apply the lemma to \(Y=r(h)-X_h(Z)\). It has mean zero. Moreover, \(X_h(Z)\in[-1,1]\) and \(r(h)\in[0,1]\), so \(|Y|\le2\). Its variance is \(\operatorname{Var}(X_h(Z))\). The lemma therefore applies when \(0<\lambda<3/2\).

Derived exponential bound: Under the Bernstein condition, for \(0<\lambda<3/2\), \(\displaystyle E\!\left[\exp\{\lambda(r(h)-X_h(Z))\}\right]\le \exp\!\left\{\frac{\lambda^2 B r(h)}{2(1-2\lambda/3)}\right\}\).

Independence of the observations lets us multiply the one-observation moment bounds. Define \(\displaystyle a_\lambda=1-\frac{\lambda B}{2(1-2\lambda/3)}\). Then

$$ E\!\left[\exp\{\lambda n(a_\lambda r(h)-\hat r(h))\}\right] \le 1. $$

Indeed, the exponent inside the expectation equals \(\lambda\sum_{i=1}^n(r(h)-X_h(Z_i))-n\lambda^2B r(h)/(2(1-2\lambda/3))\). The expectation of its exponential is bounded by the product of \(n\) identical one-observation bounds, with the second term exactly canceling the resulting upper bound.

A Uniform PAC-Bayes Fast-Rate Bound

Let \(P\) be a prior probability distribution on predictors, fixed independently of the sample. A posterior \(Q\) may depend on the sample. For distributions \(Q\) absolutely continuous with respect to \(P\), \(\operatorname{KL}(Q\|P)\) denotes their Kullback–Leibler divergence. Define posterior-averaged excess risks by \(r(Q)=E_{h\sim Q}[r(h)]\) and \(\hat r(Q)=E_{h\sim Q}[\hat r(h)]\).

Theorem: Suppose \(Z_1,\ldots,Z_n\) are i.i.d., the losses lie in \([0,1]\), a fixed risk minimizer \(h^*\) exists, and the Bernstein condition holds \(P\)-almost surely with \(B\ge1\). Choose \(0<\lambda<3/2\) such that \(a_\lambda>0\). For any \(0<\delta<1\), with probability at least \(1-\delta\), simultaneously for every posterior \(Q\ll P\) with finite \(\operatorname{KL}(Q\|P)\), \(\displaystyle r(Q)\le \frac{\hat r(Q)+\{\operatorname{KL}(Q\|P)+\log(1/\delta)\}/(\lambda n)} {a_\lambda}.\)

Proof. For each predictor, the exponential bound just derived holds. Integrating it with respect to \(P\) gives \(\displaystyle E_{Z_1^n} E_{h\sim P}[\exp\{\lambda n(a_\lambda r(h)-\hat r(h))\}]\le1\). By Markov's inequality, with probability at least \(1-\delta\), the inner prior expectation is at most \(1/\delta\).

On that event, use the change-of-measure inequality \(\displaystyle E_Q[g]\le\operatorname{KL}(Q\|P)+\log E_P[e^g]\). For completeness, this inequality follows by writing the \(Q\)-expectation on the part of the space where \(Q\) has density relative to \(P\), and applying Jensen's inequality to the logarithm. Applying it to \(g(h)=\lambda n(a_\lambda r(h)-\hat r(h))\) yields \(\displaystyle \lambda n(a_\lambda r(Q)-\hat r(Q))\le\operatorname{KL}(Q\|P)+\log(1/\delta)\). Dividing by the positive quantity \(\lambda n a_\lambda\) proves the assertion. The event was defined using the prior expectation alone, so it holds for every such \(Q\), including posteriors chosen after seeing the sample. \(\square\)

Worked Example: Applying the Bound to a Posterior

Use the Bernoulli example with \(B=1\), take \(n=100\), and suppose a predictor has empirical excess risk \(\hat r(Q)=0.02\). Let its posterior put all mass on that predictor, and let the prior assign it probability \(0.1\). Then \(\operatorname{KL}(Q\|P)=\log(10)\). Set \(\delta=0.1\) and \(\lambda=1/2\).

First check the conditions: \(\displaystyle 0<\frac12<\frac32\), and \(\displaystyle a_{1/2}=1-\frac{(1/2)(1)}{2(1-2(1/2)/3)} =1-\frac{1/2}{4/3}=\frac58>0.\) The combined complexity term is \(\displaystyle \operatorname{KL}(Q\|P)+\log(1/\delta)=\log(10)+\log(10)=2\log(10)\approx4.6052.\)

The bound is therefore \(\displaystyle r(Q)\le \frac{0.02+4.6052/(0.5\cdot100)}{5/8} =\frac{0.02+0.092104}{0.625} \approx0.1794.\) This is a high-probability upper bound on the true excess risk on the theorem's event, not a claim that this particular sample must produce a true risk equal to the bound.

Choosing a Temperature for a Fast Rate

The theorem holds for any admissible temperature, but its constants depend on \(\lambda\). A convenient choice that works uniformly for \(B\ge1\) is \(\lambda=1/(2B)\). It lies strictly between zero and \(3/2\), and

$$ a_{1/(2B)} =1-\frac{1}{4(1-1/(3B))} \ge 1-\frac38 =\frac58. $$

The inequality follows from \(B\ge1\), which implies \(1-1/(3B)\ge2/3\). Substitution into the theorem gives the explicit consequence

$$ r(Q)\le \frac85\hat r(Q) +\frac{16B}{5n} \left\{\operatorname{KL}(Q\|P)+\log(1/\delta)\right\}. $$

Thus, when the posterior's empirical excess risk is zero or of the same order as the complexity term, the resulting excess-risk bound scales as \(B\{\operatorname{KL}(Q\|P)+\log(1/\delta)\}/n\). This is the fast-rate dependence: the variance assumption has changed the complexity scale from a square-root dependence on sample size to a dependence proportional to \(1/n\).

Worked Example: A Concrete Fast-Rate Calculation

Suppose the Bernoulli-loss example is used with \(n=400\). Its Bernstein condition holds with \(B=1\), and therefore also holds with the valid, more conservative choice \(B=2\). Take \(\lambda=1/(2B)=1/4\). Let the posterior have empirical excess risk \(0.01\), and suppose \(\operatorname{KL}(Q\|P)=3\) and \(\delta=e^{-2}\), so the combined complexity is \(3+2=5\).

For \(B=2\), \(\displaystyle a_{1/4}=1-\frac{(1/4)(2)}{2(1-2(1/4)/3)} =1-\frac{1/2}{5/3}=1-\frac3{10}=\frac7{10}.\) The complexity contribution before division by \(a_{1/4}\) is \(\displaystyle \frac{5}{(1/4)(400)}=\frac5{100}=0.05.\) Consequently, \(\displaystyle r(Q)\le\frac{0.01+0.05}{0.7} =\frac{0.06}{0.7}\approx0.0857.\) Here the denominator \(\lambda n\) is \(100\), and the positive value \(a_{1/4}=0.7\) verifies that this temperature is admissible.

Common Pitfalls and Interpretation

  • Including zero as a valid temperature. The condition \(a_\lambda>0\) alone does not rule out \(\lambda=0\), since \(a_0=1\). But the bound divides by \(\lambda n\). The theorem therefore requires \(0<\lambda<3/2\), as well as \(a_\lambda>0\).
  • Treating excess loss as nonnegative. Although \(r(h)\ge0\), the observation-level difference \(X_h(Z)\) can be negative. The proof uses its boundedness in \([-1,1]\) and a variance condition; it does not assume \(X_h(Z)\in[0,1]\).
  • Dropping the positivity condition on \(a_\lambda\). A positive temperature below \(3/2\) makes the moment bound valid, but the final division also requires \(a_\lambda>0\). A temperature satisfying only the first condition is not necessarily admissible.
  • Calling the rate fast without considering empirical excess risk. The theorem includes \(\hat r(Q)\). A \(1/n\)-scale complexity term alone does not imply a \(1/n\)-scale total bound unless the empirical excess-risk term is suitably small.
Key takeaway: Under a Bernstein condition, the excess-loss variance is controlled by excess risk itself. Combining that control with an exponential-moment argument and the PAC-Bayes change-of-measure inequality yields a uniform bound whose complexity contribution is proportional to \(\{\operatorname{KL}(Q\|P)+\log(1/\delta)\}/n\), with an admissible positive temperature and a positive denominator required.

Check Your Understanding

Try these questions using the definitions and results above.

  1. Why can an excess loss be negative even though excess risk is nonnegative?
  2. For losses in \([0,1]\), why is the centered variable \(r(h)-X_h(Z)\) bounded in absolute value by \(2\)?
  3. With \(B=1\) and \(\lambda=1/2\), calculate \(a_\lambda\) and verify that the temperature is admissible.
  4. What part of the theorem's bound depends on the posterior's divergence from the prior, and how does that term scale with \(n\)?
  5. Explain why requiring \(a_\lambda>0\) does not by itself make \(\lambda=0\) a valid choice.
Clinical Biostats