Bayesian Optimization
Part III: Bayesian Optimization
中文

Acquisition Functions

Chapter 11 built the Bayesian optimization loop and ran it with one rule for choosing the next evaluation: the posterior mean plus a multiple of the posterior standard deviation. The rule worked, but its weight was a knob, and Figure 11.3 showed that turning the knob too far either way costs a great deal. A reader may reasonably ask whether there is a principled way to decide how much uncertainty is worth.

This chapter gives several answers. Each acquisition function starts from a statement about what an evaluation is for: beating the best value seen so far, improving the final recommendation, or learning where the maximum is. From that statement and the Gaussian posterior, the formula follows, and the balance between exploring and exploiting comes out of the derivation instead of being set by hand. We derive the classic acquisition functions one at a time, look at all of them on the same posterior in one and then two dimensions, and end with the problem every one of them leaves behind: finding the maximum of the acquisition function itself, which in many dimensions is a hard optimization problem of its own.

12.1 What an acquisition function is #

Recall the setting. After nn evaluations the data are Dn={(xi,yi)}i=1n\D_n = \{(\vx_i, y_i)\}_{i=1}^n, and the Gaussian process posterior gives every input x\vx a Gaussian belief about f(x)f(\vx), with mean μn(x)\mu_n(\vx) and standard deviation σn(x)\sigma_n(\vx) (Chapter 8). An acquisition function an(x)a_n(\vx) scores each input, and the loop evaluates the objective where the score is highest (Definition 11.1).

The cleanest way to build such a score is to say what we would be happy to have at the end and then ask how much one more evaluation is expected to add. Write u(D)u(\D) for the utility of a data set: a number that says how good our situation is if we stop with data D\D. If we evaluate at x\vx and observe yy, the utility changes from u(Dn)u(\D_n) to u(Dn∪{(x,y)})u(\D_n \cup \{(\vx, y)\}). We do not know yy before evaluating, but the posterior says what it is likely to be, so we can average over it.

Definition 12.1 One-step lookahead acquisition function

Given a utility uu, the one-step lookahead acquisition function is the expected gain in utility from one more evaluation at x\vx:

an(x)=En ⁣[ u(Dn∪{(x,y)})−u(Dn) ],a_n(\vx) = \E_n\!\left[\,u(\D_n \cup \{(\vx, y)\}) - u(\D_n)\,\right],
(12.1)

where En\E_n averages over the outcome yy under its posterior predictive distribution given Dn\D_n.

Different utilities give different acquisition functions. Table 12.1 previews the ones in this chapter. Two of them, the upper confidence bound and Thompson sampling, do not come from a utility at all; they come from the bandit problems of Section 13.2, where they have guarantees of a different kind (Chapter 13).

Table 12.1 Acquisition functions and the question each one answers.
Acquisition function What an evaluation is worth Section
Probability of improvement (PI) the chance of beating the best value seen so far Section 12.2
Expected improvement (EI) the expected amount by which the best value seen so far rises Section 12.3
Upper confidence bound (UCB) an optimistic estimate of the value at the input Section 12.4
Thompson sampling (TS) the chance that the input is the maximizer Section 12.5
Knowledge gradient (KG) the expected rise in the value of the final recommendation Section 12.6
Entropy search (ES, PES, MES) the expected information about the maximizer or the maximum Section 12.7

12.1.1 Why look only one step ahead #

Equation (12.1) looks one evaluation ahead, as if the next evaluation were the last. That is a simplification. With N−nN - n evaluations left, the optimal choice now depends on what we will be able to do afterward, and the next evaluation is worth more if it sets up good later ones. Writing that out gives a dynamic program in which every future outcome branches into every future choice. It is the optimal policy, and it is also, in Kushner's words, "virtually impossible to compute" (Kushner, 1964; quoted in Garnett, 2023, sec. 12.3).

So almost all acquisition functions in use are myopic: they are optimal if the next evaluation is the last one, and only approximately optimal otherwise (Frazier, 2018). The approximation may be better than it sounds. In a few special problems where the optimal multi-step policy can be computed, the myopic rules come close; in one such study, cited by Frazier (2018), the knowledge gradient came within 98% of optimal. Myopia also has a cost that is easy to see, though: a rule that ignores the future undervalues exploration, because the payoff of exploring arrives later. Several of the rules below add exploration back in one way or another.

Sources cited in Section 12.1 3
  1. Kushner (1964) A New Method of Locating the Maximum Point of an Arbitrary Multipeak Curve in the Presence of Noise
  2. Garnett (2023) Bayesian Optimization
  3. Frazier (2018) A Tutorial on Bayesian Optimization

12.2 Probability of improvement #

The oldest rule asks the simplest question: how likely is it that x\vx beats the best value seen so far (Kushner, 1964)? Write fn∗=max⁡i≤nyif^*_n = \max_{i \le n} y_i for that value, the incumbent. With exact evaluations, it is the value of the best input we could recommend right now.

The posterior says that f(x)f(\vx) is Gaussian with mean μn(x)\mu_n(\vx) and standard deviation σn(x)\sigma_n(\vx). The probability that it exceeds the incumbent by at least a margin ξ≥0\xi \ge 0 follows in three steps.

Derivation Probability of improvement
  1. Standardize: Z=(f(x)−μn(x))/σn(x)Z = (f(\vx) - \mu_n(\vx)) / \sigma_n(\vx) is a standard normal variable (Section 4.3).
  2. Rewrite the event: f(x)>fn∗+ξf(\vx) > f^*_n + \xi is the same as Z>(fn∗+ξ−μn(x))/σn(x)Z > (f^*_n + \xi - \mu_n(\vx)) / \sigma_n(\vx).
  3. Use P(Z>a)=1−Φ(a)=Φ(−a)\Prob(Z > a) = 1 - \Phi(a) = \Phi(-a), by the symmetry of the standard normal density.
PI⁡n(x)=Φ ⁣(μn(x)−fn∗−ξσn(x)).\PI_n(\vx) = \Phi\!\left(\frac{\mu_n(\vx) - f^*_n - \xi}{\sigma_n(\vx)}\right).
(12.2)

In terms of Definition 12.1, PI is the expected gain of a utility that is 1 if the best value improves by at least ξ\xi and 0 otherwise.

PI has a well-known flaw: it counts improvements but ignores their size. With ξ=0\xi = 0, an input whose mean sits just above the incumbent and whose standard deviation is tiny has PI close to 1, and the rule prefers it to an uncertain input that might improve on the incumbent by a lot. The result is a search that creeps along in tiny steps near the best point. The margin ξ\xi is the fix. Raising it asks for improvements that are worth having, which pushes the mean term in Equation (12.2) below zero for most inputs; then the only way to have a sizable probability is a large σn(x)\sigma_n(\vx), and the rule explores.

How large should ξ\xi be? Kushner suggested starting high and lowering it as the search proceeds (Brochu et al., 2010), and his papers discussed adjusting it by hand during the search (Garnett, 2023, sec. 12.3). Jones found the method "extremely sensitive to the choice of the target": too small and the search stays local, too large and it never refines a promising solution (Jones, 2001; quoted in Brochu et al., 2010). The next section's rule makes the margin far less important, because it accounts for the size of the improvement directly.

Sources cited in Section 12.2 4
  1. Kushner (1964) A New Method of Locating the Maximum Point of an Arbitrary Multipeak Curve in the Presence of Noise
  2. Brochu et al. (2010) A Tutorial on Bayesian Optimization of Expensive Cost Functions, with Application to Active User Modeling and Hierarchical Reinforcement Learning
  3. Garnett (2023) Bayesian Optimization
  4. Jones (2001) A Taxonomy of Global Optimization Methods Based on Response Surfaces

12.3 Expected improvement #

Instead of asking whether the incumbent improves, ask by how much, on average. Evaluating at x\vx raises the best value seen from fn∗f^*_n to max⁡(fn∗,f(x))\max(f^*_n, f(\vx)). The gain is the improvement max⁡(f(x)−fn∗,0)\max(f(\vx) - f^*_n, 0), which is zero when f(x)f(\vx) falls short, and its expectation under the posterior is the expected improvement:

EI⁡n(x)=En ⁣[max⁡ ⁣(f(x)−fn∗,  0)].\EI_n(\vx) = \E_n\!\left[\max\!\left(f(\vx) - f^*_n,\; 0\right)\right].
(12.3)

This is Equation (12.1) with the utility u(D)=max⁡iyiu(\D) = \max_i y_i, the best value observed. EI is usually credited to Močkus and his colleagues (Močkus, 1975; Frazier, 2018), with an earlier explicit formula traced to Šaltenis in 1971 (Garnett, 2023, sec. 12.3), and it became standard through the EGO algorithm of Jones et al. (1998).

The difference f(x)−fn∗f(\vx) - f^*_n is a Gaussian variable, since fn∗f^*_n is a known number. So everything reduces to one fact about Gaussians, which we state for any Gaussian DD because Section 19.4 uses it for a different one.

Derivation The expected positive part of a Gaussian

Let DD be Gaussian with mean δ\delta and standard deviation s>0s > 0. We want E[max⁡(D,0)]\E[\max(D, 0)].

  1. Write D=δ+sZD = \delta + s Z with ZZ standard normal (Section 4.3).
  2. max⁡(D,0)\max(D, 0) is zero unless D>0D > 0, that is, unless Z>−δ/sZ > -\delta/s. Therefore E[max⁡(D,0)]=∫−δ/s∞(δ+sz) ϕ(z) dz\E[\max(D, 0)] = \int_{-\delta/s}^{\infty} (\delta + s z)\, \phi(z)\, \dd z, where ϕ\phi is the standard normal density.
  3. Split the integral into two: δ∫−δ/s∞ϕ(z) dz+s∫−δ/s∞z ϕ(z) dz\delta \int_{-\delta/s}^{\infty} \phi(z)\, \dd z + s \int_{-\delta/s}^{\infty} z\, \phi(z)\, \dd z.
  4. The first integral is 1−Φ(−δ/s)=Φ(δ/s)1 - \Phi(-\delta/s) = \Phi(\delta/s), by the symmetry of ϕ\phi.
  5. For the second, the density satisfies ϕ′(z)=−z ϕ(z)\phi'(z) = -z\,\phi(z), so z ϕ(z)z\,\phi(z) has antiderivative −ϕ(z)-\phi(z), and ∫a∞z ϕ(z) dz=ϕ(a)\int_{a}^{\infty} z\,\phi(z)\, \dd z = \phi(a). With a=−δ/sa = -\delta/s and ϕ(−a)=ϕ(a)\phi(-a) = \phi(a), the second integral is ϕ(δ/s)\phi(\delta/s).
  6. Combine the two terms.
E[max⁡(D,0)]=δ Φ ⁣(δs)+s ϕ ⁣(δs).\E[\max(D, 0)] = \delta\, \Phi\!\left(\frac{\delta}{s}\right) + s\, \phi\!\left(\frac{\delta}{s}\right).
(12.4)

When s=0s = 0, DD is the constant δ\delta and the expectation is max⁡(δ,0)\max(\delta, 0), which is also the limit of Equation (12.4) as s→0s \to 0.

For expected improvement, take D=f(x)−fn∗−ξD = f(\vx) - f^*_n - \xi, with the same optional margin ξ\xi as in PI. Its mean is δ=μn(x)−fn∗−ξ\delta = \mu_n(\vx) - f^*_n - \xi and its standard deviation is s=σn(x)s = \sigma_n(\vx):

EI⁡n(x)=(μn(x)−fn∗−ξ)Φ(z)+σn(x) ϕ(z),z=μn(x)−fn∗−ξσn(x).\EI_n(\vx) = \left(\mu_n(\vx) - f^*_n - \xi\right) \Phi(z) + \sigma_n(\vx)\, \phi(z), \qquad z = \frac{\mu_n(\vx) - f^*_n - \xi}{\sigma_n(\vx)}.
(12.5)

This is the closed form that Jones et al. (1998) made standard, with the margin ξ\xi as a later addition. Brochu et al. (2010) report experiments by Lizotte suggesting that ξ=0.01\xi = 0.01, scaled by the signal variance if necessary, works well in almost all cases.

12.3.1 Reading the formula #

The two terms of Equation (12.5) are exploitation and exploration in one expression. The first is large where the mean is above the incumbent. The second is large where the standard deviation is large. Unlike the upper confidence bound, nobody chose the exchange rate between them: it comes out of the integral.

Three properties make this precise. Write EI⁡(δ,s)\EI(\delta, s) for the right-hand side of Equation (12.4).

  • EI is never below the improvement of the mean. Since max⁡(⋅,0)\max(\cdot, 0) is convex, Jensen's inequality gives E[max⁡(D,0)]≥max⁡(E[D],0)=max⁡(δ,0)\E[\max(D, 0)] \ge \max(\E[D], 0) = \max(\delta, 0). Uncertainty can only add value.
  • At a mean equal to the incumbent, EI is about 0.4 s0.4\,s. With δ=0\delta = 0, Equation (12.4) gives EI⁡=s ϕ(0)=s/2π≈0.399 s\EI = s\,\phi(0) = s / \sqrt{2\pi} \approx 0.399\,s. This is the example of Section 2.6, where the improvement of the mean is zero but the expected improvement is not.
  • EI increases with both the mean and the uncertainty. The partial derivatives are ∂EI⁡/∂δ=Φ(δ/s)\partial \EI / \partial \delta = \Phi(\delta/s) and ∂EI⁡/∂s=ϕ(δ/s)\partial \EI / \partial s = \phi(\delta/s) (Exercise 12.1), and both are positive. More uncertainty always makes EI larger, wherever the mean is.

The last property is where EI and PI part ways. PI's derivative with respect to ss is −(δ/s2) ϕ(δ/s)-(\delta/s^2)\,\phi(\delta/s), which is negative whenever δ>0\delta > 0: once the mean is above the incumbent, PI prefers certainty. Figure 12.1 shows both quantities for a single input.

density of DP(D > 0) (area = PI)max(D, 0) × density (area = EI)δ = −0.30, s = 0.50: PI = 0.274, EI = 0.0840.00.51.0−3−2−10123improvement over the best value so far, D = f(x) − f*ₙf*ₙδPI as s grows (δ fixed)0.00.20.40.60.81.00.00.51.01.5standard deviation sEI as s grows (δ fixed)0.00.20.40.00.51.01.5standard deviation s
density of DP(D > 0) (area = PI)max(D, 0) × density (area = EI)δ = −0.30, s = 0.50: PI = 0.274, EI = 0.0840.00.51.0−3−2−10123D = f(x) − f*ₙf*ₙδPI as s grows (δ fixed)0.00.20.40.60.81.00.00.51.01.5standard deviation sEI as s grows (δ fixed)0.00.20.40.00.51.01.5standard deviation s
Figure 12.1 Improvement at a single input. Top: the density of D=f(x)−fn∗D = f(x) - f^*_n, Gaussian with mean δ\delta and standard deviation ss set by the sliders. The shaded area right of zero is the probability of improvement; the dashed curve is the improvement max⁡(D,0)\max(D, 0) times the density, and its area is the expected improvement, Equation (12.4). Bottom: PI and EI as ss varies with δ\delta held fixed; the dot is the current ss. When δ>0\delta > 0, the dashed line in the EI panel marks δ\delta, the value EI approaches as ss shrinks.

Three settings show the difference.

A mean below the incumbent. The figure opens with δ=−0.3\delta = -0.3. Both PI and EI grow as ss grows: the only way to beat the incumbent is for the function to be higher than the model expects, and more uncertainty makes that more likely.

A mean above the incumbent. Set δ=0.5\delta = 0.5. Now PI falls as ss grows, because a wider belief puts more weight on falling short. EI still rises: the extra weight on large improvements outweighs the extra weight on falling short, which costs nothing, since improvement is never negative.

A tiny, certain improvement. Set δ=0.05\delta = 0.05 and s=0.05s = 0.05. PI is about 0.84, while EI is only about 0.05. An input with δ=−0.3\delta = -0.3 and s=1s = 1 has a PI of only 0.38, but its EI is about 0.27, about five times larger. EI ranks the second input higher; PI ranks the first.

Pitfall Expected improvement underflows

Far from the data in a large domain, or late in a run when the incumbent is high, δ/s\delta / s is very negative and Equation (12.5) is the difference of numbers so small that floating point rounds them to zero. The acquisition function then has value and gradient exactly zero on most of the domain, and a gradient-based optimizer started there cannot move. Ament et al. (2023) argued that this numerical problem, rather than the idea of expected improvement, is behind EI's inconsistent and often weak performance in the literature, and proposed LogEI, which computes log⁡EI⁡\log \EI with formulas that stay accurate in the tail. Its maximizers are the same as EI's or nearly so, and in their experiments it matched or beat more recent acquisition functions. BoTorch provides it as LogExpectedImprovement.

Two practical notes complete the picture. First, Equation (12.5) assumes exact evaluations, so that fn∗f^*_n is a known value. With noise the best observed value is itself uncertain and biased upward, and several noisy variants replace it; Section 14.2 compares them. Second, a real application shows the formula at work. Snoek et al. (2012) tuned machine learning algorithms with expected improvement, averaging Equation (12.5) over samples of the Gaussian process hyperparameters instead of fixing them. They also modeled the training time with a second Gaussian process and maximized expected improvement per second, which prefers inputs that are both promising and quick to evaluate. Chapter 22 replays a problem of this kind.

Sources cited in Section 12.3 7
  1. Močkus (1975) On Bayesian Methods for Seeking the Extremum
  2. Frazier (2018) A Tutorial on Bayesian Optimization
  3. Garnett (2023) Bayesian Optimization
  4. Jones et al. (1998) Efficient Global Optimization of Expensive Black-Box Functions
  5. Brochu et al. (2010) A Tutorial on Bayesian Optimization of Expensive Cost Functions, with Application to Active User Modeling and Hierarchical Reinforcement Learning
  6. Ament et al. (2023) Unexpected Improvements to Expected Improvement for Bayesian Optimization
  7. Snoek et al. (2012) Practical Bayesian Optimization of Machine Learning Algorithms

12.4 Upper confidence bounds #

The upper confidence bound is the rule Chapter 11 already used:

UCB⁡n(x)=μn(x)+β1/2 σn(x).\UCB_n(\vx) = \mu_n(\vx) + \beta^{1/2}\, \sigma_n(\vx).
(12.6)

Its principle comes from the bandit literature (Section 13.2) and is called optimism in the face of uncertainty: act as if the world were as good as it plausibly could be, then let the evaluation correct you. If the optimism was justified, the evaluation finds a good input; if not, the evaluation shrinks σn(x)\sigma_n(\vx) there and the inflated estimate deflates, so the rule moves on.

The weight has a probabilistic reading. Under the posterior, P(f(x)≤μn(x)+β1/2σn(x))=Φ(β1/2)\Prob(f(\vx) \le \mu_n(\vx) + \beta^{1/2} \sigma_n(\vx)) = \Phi(\beta^{1/2}), so Equation (12.6) is a quantile of the belief about f(x)f(\vx). With β1/2=2\beta^{1/2} = 2 it is the 97.7% quantile, and maximizing it picks the input whose plausible best case is highest.

What should β\beta be? Srinivas et al. (2010) answered with a schedule that grows slowly with the number of evaluations tt. For a finite domain X\X of candidate inputs and a confidence parameter δ∈(0,1)\delta \in (0, 1), their GP-UCB rule uses

βt=2log⁡ ⁣(∣X∣ t2π26δ),\beta_t = 2 \log\!\left(\frac{|\X|\, t^2 \pi^2}{6 \delta}\right),
(12.7)

and they proved that with this schedule the regret grows sublinearly, so the average gap to the maximum goes to zero (Section 13.4 gives the theorem and its proof). The schedule is just large enough that, with probability at least 1−δ1 - \delta, the bands μ±βt1/2σ\mu \pm \beta_t^{1/2} \sigma contain the true function at every candidate and every step at once. For continuous domains, the schedule gains a term proportional to dlog⁡td \log t (Srinivas et al., 2010).

The numbers show how cautious the theory is. With ∣X∣=1000|\X| = 1000 candidates and δ=0.1\delta = 0.1, Equation (12.7) gives βt1/2≈5.4\beta_t^{1/2} \approx 5.4 at t=10t = 10 and ≈6.2\approx 6.2 at t=100t = 100: five to six standard deviations of optimism. Figure 11.3 found weights of 1 to 2 best on the running example, and weights near 6 noticeably worse. The authors themselves found that their algorithm improved when βt\beta_t was scaled down by a factor of 5 (Srinivas et al., 2010). In practice, libraries take a constant β\beta from the user; BoTorch's UpperConfidenceBound computes the mean plus β\sqrt{\beta} times the standard deviation. The schedule matters for the proof, which needs exploration that never switches off. A constant that works well over a fixed budget is a different, practical question.

Sources cited in Section 12.4 1
  1. Srinivas et al. (2010) Gaussian Process Optimization in the Bandit Setting: No Regret and Experimental Design

12.5 Thompson sampling #

The oldest idea in this chapter is from 1933. Thompson (1933) considered two medical treatments of unknown effectiveness and proposed assigning each new patient a treatment with the probability that it is the better one, given the evidence so far. For a Gaussian process the rule is:

  1. Draw one function gg from the posterior given Dn\D_n (Section 8.5).
  2. Evaluate the objective where that sample is largest: xn+1∈arg max⁡xg(x)\vx_{n+1} \in \argmax_{\vx} g(\vx).

The first step is the only random one, and it is what makes the rule work. Given the data, the sample gg and the unknown ff have the same distribution, so the maximizer of gg has the same distribution as the maximizer of ff:

P ⁣(xn+1∈A∣Dn)=P ⁣(x⋆∈A∣Dn)for every region A.\Prob\!\left(\vx_{n+1} \in A \mid \D_n\right) = \Prob\!\left(\vx^\star \in A \mid \D_n\right) \quad \text{for every region } A.
(12.8)

This is called probability matching: Thompson sampling evaluates each region exactly as often as the model believes the maximum lies there. A region the model is sure is poor is almost never chosen. A region that could hide the maximum is chosen in proportion to how likely that is, however uncertain the rest of the model is.

Thompson sampling has no weight or margin to tune, and it parallelizes naturally: to choose ten evaluations at once, draw ten samples and take each one's maximizer. Its guarantees are close to those of UCB. Russo and Van Roy (2014) established a connection between posterior sampling and upper confidence bound algorithms that converts regret bounds proved for UCB algorithms into Bayesian regret bounds for posterior sampling, including one for Gaussian process models, and Chowdhury and Gopalan (2017) proved a regret bound for a Gaussian process version when the unknown function is fixed rather than drawn from the prior.

The cost lies in step 1. A sample on a grid of mm inputs needs a Cholesky factorization of the m×mm \times m posterior covariance, O(m3)O(m^3), which limits exact sampling to a few thousand inputs. In more dimensions, implementations draw the sample on a candidate set, a few thousand points chosen to cover the promising regions, or draw approximate sample functions that can be evaluated anywhere, built from a finite set of random basis functions (random features) or from a prior sample corrected by the data (pathwise updates), and maximize them with gradients (Rahimi and Recht, 2007; Wilson et al., 2020). Section 12.9 explains why the choice of candidate set becomes the hard part in many dimensions.

Sources cited in Section 12.5 5
  1. Thompson (1933) On the Likelihood that One Unknown Probability Exceeds Another in View of the Evidence of Two Samples
  2. Russo and Van Roy (2014) Learning to Optimize via Posterior Sampling
  3. Chowdhury and Gopalan (2017) On Kernelized Multi-armed Bandits
  4. Rahimi and Recht (2007) Random Features for Large-Scale Kernel Machines
  5. Wilson et al. (2020) Efficiently Sampling Functions from Gaussian Process Posteriors

12.6 Knowledge gradient #

Expected improvement makes a quiet assumption: at the end, we recommend one of the inputs we evaluated, the one with the best observed value (Frazier, 2018). Often we would happily recommend an input we never evaluated, if the model is confident it is good. And with noisy evaluations, no observed value can be trusted at face value anyway, so the natural recommendation is the input with the highest posterior mean (Section 11.2.3).

The knowledge gradient takes that recommendation seriously. Its utility is the value of the final recommendation: if we stopped now, we would recommend the maximizer of the posterior mean, and its expected value under the posterior is

u(Dn)=max⁡x′μn(x′)=:μn∗.u(\D_n) = \max_{\vx'} \mu_n(\vx') =: \mu^*_n.

One more evaluation at x\vx changes the posterior mean everywhere, not only at x\vx, so it can raise μ∗\mu^* even if f(x)f(\vx) itself turns out to be mediocre. Plugging this utility into Equation (12.1) gives the knowledge gradient:

KGn(x)=En ⁣[ max⁡x′μn+1(x′)  |  xn+1=x]−max⁡x′μn(x′).\mathrm{KG}_n(\vx) = \E_n\!\left[\,\max_{\vx'} \mu_{n+1}(\vx') \;\middle|\; \vx_{n+1} = \vx\right] - \max_{\vx'} \mu_n(\vx').
(12.9)

The value of a query in this sense is the expected value of the final recommendation after one more answer. A query that maximizes it is one-step Bayes optimal: if the session ended after this one evaluation, no other choice would leave a better recommendation in expectation, and the knowledge gradient is the acquisition function that picks it. Section 19.4.1 relies on exactly this property when queries are pairs of options.

To compute Equation (12.9) we need to know how the posterior mean moves when one observation arrives.

Derivation The posterior mean after one more observation

Let the next observation be y=f(x)+εy = f(\vx) + \varepsilon with noise variance σε2\sigma_\varepsilon^2. (This is the noise variance that the rest of the book writes σn2\sigma_n^2; it is renamed in this section only, because the posterior variance σn2(x)\sigma_n^2(\vx) stands next to it in every formula.) Write kn(x′,x)k_n(\vx', \vx) for the posterior covariance between f(x′)f(\vx') and f(x)f(\vx) given Dn\D_n.

  1. Given Dn\D_n, the pair (f(x′),y)(f(\vx'), y) is jointly Gaussian with means μn(x′)\mu_n(\vx') and μn(x)\mu_n(\vx), variance of yy equal to σn2(x)+σε2\sigma_n^2(\vx) + \sigma_\varepsilon^2, and covariance kn(x′,x)k_n(\vx', \vx), since the noise is independent of ff.
  2. Conditioning on yy (Section 4.5) gives μn+1(x′)=μn(x′)+kn(x′,x)σn2(x)+σε2 (y−μn(x))\mu_{n+1}(\vx') = \mu_n(\vx') + \dfrac{k_n(\vx', \vx)}{\sigma_n^2(\vx) + \sigma_\varepsilon^2}\,(y - \mu_n(\vx)).
  3. Before we observe it, y−μn(x)y - \mu_n(\vx) is Gaussian with mean zero and standard deviation σn2(x)+σε2\sqrt{\sigma_n^2(\vx) + \sigma_\varepsilon^2}, so it equals that standard deviation times a standard normal ZZ.
  4. Substitute into step 2.
μn+1(x′)=μn(x′)+σ~n(x′,x) Z,σ~n(x′,x)=kn(x′,x)σn2(x)+σε2.\mu_{n+1}(\vx') = \mu_n(\vx') + \tilde\sigma_n(\vx', \vx)\, Z, \qquad \tilde\sigma_n(\vx', \vx) = \frac{k_n(\vx', \vx)}{\sqrt{\sigma_n^2(\vx) + \sigma_\varepsilon^2}}.
(12.10)

Every point of the new posterior mean moves by a multiple of the same standard normal ZZ, because a single number, the outcome yy, moves them all. Inputs strongly correlated with x\vx move a lot; inputs far from x\vx hardly move. So the knowledge gradient is

KGn(x)=E ⁣[max⁡x′(μn(x′)+σ~n(x′,x) Z)]−max⁡x′μn(x′).\mathrm{KG}_n(\vx) = \E\!\left[\max_{\vx'} \left(\mu_n(\vx') + \tilde\sigma_n(\vx', \vx)\, Z\right)\right] - \max_{\vx'} \mu_n(\vx').
(12.11)

Three consequences follow from this form.

  • KG is never negative. The maximum of functions is convex, and ZZ has mean zero, so by Jensen's inequality the expected maximum is at least the maximum at Z=0Z = 0, which is μn∗\mu^*_n. Information never hurts in expectation.
  • An exact repeat is worth nothing. If x\vx was already evaluated without noise, σn(x)=0\sigma_n(\vx) = 0 and kn(x′,x)=0k_n(\vx', \vx) = 0 for every x′\vx', so nothing moves and KGn(x)=0\mathrm{KG}_n(\vx) = 0. With noise (σε>0\sigma_\varepsilon > 0), repeating an evaluation can still be worth something, which is why KG handles noisy problems gracefully (Frazier, 2018).
  • With two inputs in play, KG is Clark's formula. If the maximum in Equation (12.11) runs over only two inputs, it is the maximum of two jointly Gaussian values, a1+b1Za_1 + b_1 Z and a2+b2Za_2 + b_2 Z, and its expectation is the formula of Clark (1961) (Section B.5). The same formula returns in preferential Bayesian optimization (PBO), where a query is a pair of options and the acquisition function is the expected utility of the better one (EUBO, Equation (19.3)); with noise-free answers it has the knowledge gradient's one-step optimality (Section 19.4.1).

The knowledge gradient also clarifies expected improvement. If the recommendation must be an evaluated input and evaluations are exact, the utility in Equation (12.1) becomes the best observed value, and the one-step gain is exactly EI (Frazier, 2018). EI is the knowledge gradient of a decision maker who will only recommend what has been measured.

Figure 12.2 makes the lookahead visible.

posterior mean nowmean after one more evaluation at x (7 outcomes)maximum of eachx = 0.62: best mean now 0.52, expected best mean after 0.61, KG = 0.091−1.0−0.50.00.51.01.5f(x)best mean now μ*0.00.10.20.00.20.40.60.81.0input xknowledge gradient
posterior mean nowmean after one more evaluation at x (7 outcomes)maximum of eachx = 0.62: μ* now 0.52, after 0.61, KG = 0.091−1.0−0.50.00.51.01.5f(x)best mean now μ*0.00.10.20.00.20.40.60.81.0input xknowledge gradient
Figure 12.2 The knowledge gradient as a one-step lookahead on the running objective. Choose a candidate xx (orange) with the slider or by clicking. The violet curves are the posterior means the model would have after evaluating there, Equation (12.10), for seven equally likely outcomes ZZ (the quantiles of the predictive distribution); dots mark where each is highest, and the dashed blue line is the highest mean now, μn∗\mu^*_n. The knowledge gradient is the expected height of the new maximum minus μn∗\mu^*_n, averaged over all outcomes, not only the seven drawn. The strip shows it for every candidate, computed exactly; the black triangle marks its maximum. Evaluate at x adds the candidate to the data.

Look where the violet curves fan out. At the default candidate, in the unexplored gap on the right, the fantasies spread widely: a high outcome would put a new maximum of the mean there, a low one would leave the old maximum in place. Since a low outcome cannot lower μ∗\mu^* (the old maximum is still available) while a high one raises it, the average rises.

Move the candidate onto an evaluated point. The violet curves collapse onto the blue one and the readout shows KG equal to zero, the second consequence above. Now move it a little to either side: KG jumps back up. Two exact evaluations very close together reveal the slope of ff between them, and near the top of a bump a slope can move the maximum of the mean. The narrow notches in the strip are this effect.

Compare with the strip. The knowledge gradient is largest around the current best region, not in the middle of the widest gap. Near the best point, an evaluation directly moves the maximum of the mean; in the far gap, an outcome must be large to matter at all. KG explores less than UCB with β1/2=2\beta^{1/2} = 2, a pattern Figure 12.3 shows again.

Add noise. Set the noise to 0.2. The fantasies spread less, because a noisy outcome moves the mean less, and the notches widen into valleys. At the evaluated inputs on the broad bump, KG is now slightly positive: a second noisy measurement there could still move the maximum of the mean. At the evaluated input in the dip near x=0.45x = 0.45 it stays at zero, since no outcome there could make that region the best.

The knowledge gradient was introduced for choosing among a finite set of alternatives with independent beliefs (Frazier et al., 2008) and extended to correlated beliefs (Frazier et al., 2009), the setting of a Gaussian process on a grid. On a finite set, Equation (12.11) can be computed exactly: the maximum of the lines aj+bjza_j + b_j z is a piecewise linear function of zz, and integrating each piece against the normal density gives a closed form (Frazier et al., 2009); Figure 12.2 does exactly this. On a continuous domain the inner maximum has no closed form, and implementations estimate KG by simulating outcomes, re-solving the inner maximization for each (Frazier, 2018), or, as in BoTorch, by optimizing the candidate together with one maximizer per simulated outcome in a single "one-shot" problem (Balandat et al., 2020). (Section 11.5 tells how the knowledge gradient and expected improvement were entangled at their origin.)

Sources cited in Section 12.6 5
  1. Frazier (2018) A Tutorial on Bayesian Optimization
  2. Clark (1961) The Greatest of a Finite Set of Random Variables
  3. Frazier et al. (2008) A Knowledge-Gradient Policy for Sequential Information Collection
  4. Frazier et al. (2009) The Knowledge-Gradient Policy for Correlated Normal Beliefs
  5. Balandat et al. (2020) BoTorch: A Framework for Efficient Monte-Carlo Bayesian Optimization

The rules so far value an evaluation by what it does for a final answer. A different family values it by what it teaches about the maximum. The posterior over ff induces a distribution over the location of the maximum, p(x⋆∣Dn)p(\vx^\star \mid \D_n): draw a function from the posterior, find where it is largest, and repeat. Where this distribution is spread out, we do not know where the maximum is. An evaluation is valuable if it is expected to concentrate the distribution.

Entropy, from Section 6.1, measures the spread of a distribution in a way that depends only on probabilities, not on distances. Entropy search picks the evaluation that most reduces the entropy of p(x⋆∣D)p(\vx^\star \mid \D) in expectation:

ESn(x)=H ⁣[p(x⋆∣Dn)]−En ⁣[H ⁣[p(x⋆∣Dn∪{(x,y)})]].\mathrm{ES}_n(\vx) = H\!\left[p(\vx^\star \mid \D_n)\right] - \E_n\!\left[H\!\left[p(\vx^\star \mid \D_n \cup \{(\vx, y)\})\right]\right].
(12.12)

The expected reduction in entropy is the mutual information between the outcome yy and x⋆\vx^\star (Section 6.3), and Equation (12.12) is Equation (12.1) with the negative entropy of x⋆\vx^\star as the utility. The idea was proposed by Villemonteix et al. (2009) and independently by Hennig and Schuler (2012), who coined the name (Garnett, 2023, sec. 12.4).

Computing Equation (12.12) is hard: the distribution of x⋆\vx^\star has no closed form, its entropy must be approximated, and that approximation must be repeated for every hypothetical outcome yy. Two reformulations made the idea practical.

Predictive entropy search uses the symmetry of mutual information. The information that yy carries about x⋆\vx^\star equals the information that x⋆\vx^\star carries about yy, so

PESn(x)=H ⁣[p(y∣Dn,x)]−Ex⋆ ⁣[H ⁣[p(y∣Dn,x,x⋆)]].\mathrm{PES}_n(\vx) = H\!\left[p(y \mid \D_n, \vx)\right] - \E_{\vx^\star}\!\left[H\!\left[p(y \mid \D_n, \vx, \vx^\star)\right]\right].

The first term is the entropy of a Gaussian, available in closed form; the second averages over sampled maximizers, each requiring an approximation of how knowing x⋆\vx^\star would change the prediction at x\vx (Hernández-Lobato et al., 2014). Exact ES and PES are the same function; their approximations differ (Frazier, 2018).

Max-value entropy search (MES) changes the target: it asks for information about the maximum value f⋆=f(x⋆)f^\star = f(\vx^\star), a single number, instead of its location (Wang and Jegelka, 2017). Knowing f⋆f^\star tells us one simple thing about f(x)f(\vx): it cannot exceed f⋆f^\star. So the belief about f(x)f(\vx) given f⋆f^\star is the Gaussian posterior cut off above f⋆f^\star, a truncated Gaussian whose entropy has a closed form. Averaging over KK sampled maximum values f1⋆,…,fK⋆f^\star_1, \dots, f^\star_K gives

MESn(x)≈1K∑k=1K[γk(x) ϕ(γk(x))2 Φ(γk(x))−log⁡Φ(γk(x))],γk(x)=fk⋆−μn(x)σn(x),\mathrm{MES}_n(\vx) \approx \frac{1}{K} \sum_{k=1}^{K} \left[\frac{\gamma_k(\vx)\, \phi(\gamma_k(\vx))}{2\, \Phi(\gamma_k(\vx))} - \log \Phi(\gamma_k(\vx))\right], \qquad \gamma_k(\vx) = \frac{f^\star_k - \mu_n(\vx)}{\sigma_n(\vx)},
(12.13)

which is equation (6) of Wang and Jegelka (2017). The samples fk⋆f^\star_k can be taken as the maxima of posterior sample functions, or drawn from a cheaper approximation of their distribution. Each term is large when γk\gamma_k is small, that is, when the sampled maximum is not far above the mean at x\vx, measured in standard deviations: an evaluation there could reveal whether the maximum is about that high. The authors report that MES matches or improves on ES and PES at a fraction of the cost, and that it is much less sensitive to the number of samples (Wang and Jegelka, 2017).

Sources cited in Section 12.7 6
  1. Villemonteix et al. (2009) An Informational Approach to the Global Optimization of Expensive-to-Evaluate Functions
  2. Hennig and Schuler (2012) Entropy Search for Information-Efficient Global Optimization
  3. Garnett (2023) Bayesian Optimization
  4. Hernández-Lobato et al. (2014) Predictive Entropy Search for Efficient Global Optimization of Black-box Functions
  5. Frazier (2018) A Tutorial on Bayesian Optimization
  6. Wang and Jegelka (2017) Max-value Entropy Search for Efficient Bayesian Optimization

12.8 Comparing them #

Each rule has now been derived on its own. To see how differently they behave, Figure 12.3 puts all six on one posterior of the running objective. You play the optimizer: click the plot to evaluate the objective anywhere, and watch where each rule would go next.

hidden objectiveposterior mean95% bandp(x*): where the maximum may beEI would evaluate x = 0.19−1.0−0.50.00.51.01.5f(x)PIEIUCBThompsonKGMES0.00.20.40.60.81.0input x
hidden objectiveposterior mean95% bandp(x*): where the maximum may beEI would evaluate x = 0.19−1.0−0.50.00.51.01.5f(x)PIEIUCBTSKGMES0.00.20.40.60.81.0input x
Figure 12.3 Six acquisition functions on one posterior. Top: the running objective (dashed), the posterior after the evaluations so far (dots), and, in violet bars, how often each input was the maximizer among 64 posterior samples, an estimate of p(x⋆∣Dn)p(x^\star \mid \mathcal{D}_n). Click the plot to evaluate the objective there; click a dot to remove it. Below: PI and EI (Equation (12.2), Equation (12.5), margin ξ\xi), UCB (Equation (12.6), weight β1/2\beta^{1/2}), one Thompson sample, the knowledge gradient (Equation (12.11), exact), and MES (Equation (12.13), from the maxima of the 64 samples). Each strip is rescaled to fill its height, so only its shape and the location of its maximum (dot) matter. The selected rule is orange; its next query is the orange line on the posterior. Evaluate its maximum runs one step of the loop with it; New samples redraws the random samples behind Thompson sampling and MES.

The default posterior has four evaluations: two on the broad bump, one in the dip after it, and one at the far right. The tall bump near x=0.73x = 0.73 sits in an unexplored gap. Some guided experiments:

The rules disagree. PI, EI, MES, and KG choose near the broad bump, at xx between about 0.19 and 0.27, where the mean is already close to the incumbent and a modest improvement is likely. UCB with β1/2=2\beta^{1/2} = 2 goes into the gap, to x≈0.68x \approx 0.68, where the upper edge of the band is highest. Thompson sampling depends on its sample: press New samples a few times and its choice jumps among the broad bump, the gap, and the left edge, roughly in proportion to the violet bars.

Raise the margin. Move ξ\xi up from 0.01. At ξ=0.1\xi = 0.1, EI already switches to the gap: asking for an improvement of at least 0.1 makes the small, likely gains near the broad bump worthless. PI holds on to the broad bump until ξ\xi reaches 0.39. Both rules change their choice abruptly at some margin, which is the sensitivity that Jones warned about.

Run the loop. Pick a rule and press Evaluate its maximum repeatedly, then press Reset and try another. Every rule reaches the tall bump eventually, by different routes: UCB goes there first, EI, KG, and MES after one more evaluation on the broad bump, PI after two, and Thompson sampling later still. On this posterior PI happens to come within 0.05 of the maximum fastest, and KG, which is trying to improve the maximum of the mean rather than the best observed value, is slowest by the best-observed yardstick. One run on one problem ranks nothing.

Watch the violet bars. Once the tall bump has been evaluated, the estimated distribution of x⋆x^\star collapses onto it. Thompson sampling and MES then concentrate their evaluations there; UCB keeps visiting other regions while their bands are wide.

No rule is best on every problem. Comparisons on benchmark functions favor different rules on different problems, and the regret bounds of Section 13.5.2 are proved in different settings for different rules, so they do not rank them either (inference). Table 12.2 lists the practical differences that do hold.

Table 12.2 Practical properties of the acquisition functions in this chapter.
Rule Closed form for a GP? Parameter to set Values evaluations by Cost per candidate
PI yes, Equation (12.2) margin ξ\xi, sensitive chance of beating the incumbent one prediction
EI yes, Equation (12.5) margin ξ\xi, often 0 or small expected gain over the incumbent one prediction
UCB yes, Equation (12.6) weight β\beta, matters optimistic value one prediction
Thompson no; a random sample none chance of being the maximizer one joint sample over all candidates
KG on a finite set, Equation (12.11) none gain in the recommended value a maximization per outcome
ES, PES no none information about x⋆\vx^\star expensive approximations
MES given sampled maxima, Equation (12.13) number of samples information about f⋆=f(x⋆)f^\star = f(\vx^\star) one prediction per sample

12.8.1 In two dimensions #

One-dimensional pictures hide an important fact: the number of places to look grows exponentially with dimension, while the posterior is informative only near the data. Figure 12.4 repeats the comparison on a two-dimensional problem, the Branin function, a standard test function with three global maxima of equal height (rescaled here to the unit square and negated so that larger is better).

6 evaluations; best value 0.62 (max 0.99); EI picks (0.63, 0.37)hidden objective (3 maxima, +)+++posterior meanposterior sdEI
6 evaluations; best value 0.62 (max 0.99); EI picks (0.63, 0.37)hidden objective (3 maxima, +)+++posterior meanposterior sdEI
Figure 12.4 Acquisition functions on the two-dimensional Branin function, after six initial evaluations (dots). Top left: the hidden objective, with its three global maxima marked +; values below −1.5 (one corner falls to about −4.7) are drawn as the faintest shade. Top right: the posterior mean on the same color scale. Bottom left: the posterior standard deviation. Bottom right: the selected acquisition function (for Thompson sampling, one posterior sample). In every panel, a stronger color means a higher value. The orange ring on every panel is the selected rule's next query. Click any panel to evaluate the objective there; Evaluate the maximum lets the rule choose. The grid has 31 by 31 points, which also serve as the candidates.

Compare the bottom two panels. The standard deviation is low only in small disks around the six evaluations; almost the whole square is uncertain. EI is large where a fairly high mean meets a large standard deviation, here a broad region between the evaluations in the lower half, and small both on top of the evaluations and where the mean is low, in the upper right.

Switch between rules. PI and KG choose close to the best evaluation, since an evaluation there is likely to raise the incumbent or the maximum of the mean. UCB and MES reach farther out. Thompson sampling's sample is a whole surface, with its own peaks in unexplored corners; its maximizer can land anywhere the model allows a maximum.

Run the loop. Select PI and press Evaluate the maximum ten times. The evaluations creep in small steps from the best initial point down the slope to the maximum near (0.54,0.15)(0.54, 0.15): the cautious behavior of Section 12.2, which here happens to work. Reset and do the same with EI or UCB. Several of their evaluations go to the edges and corners of the square, where the standard deviation stays large because no evaluation lies beyond them, and the rest land near two of the three maxima. With three maxima of equal height, which one a run finds first depends on its first few evaluations.

Imagine six dimensions. In the figure the uncertain region is most of the square, and a 31 by 31 grid of candidates covers it finely. The same grid in six dimensions would have 316≈9×10831^6 \approx 9 \times 10^8 points. The acquisition function would still be informative only near the data, now in a tiny fraction of the volume. Finding its maximum is the subject of the next section.

12.9 Optimizing the acquisition function #

Every rule in this chapter ends with "evaluate where the acquisition function is largest." The figures did that by checking every point of a grid. That is fine in one or two dimensions and impossible in ten. Maximizing the acquisition function is a global optimization problem of its own, and the loop solves one at every step.

What makes it workable is cost. One evaluation of EI or UCB needs one posterior prediction, O(n)O(n) for the mean and O(n2)O(n^2) for the variance after the Cholesky factorization is done once per step (Section 8.4). With a few hundred observations that is microseconds, so an optimizer can afford tens of thousands of acquisition evaluations per step, while the objective, which takes hours, gets one. The acquisition function is also smooth and, for a Gaussian process, differentiable in closed form, so gradient methods apply (Frazier, 2018).

What makes it hard is shape. Acquisition functions are nonconvex and have many local maxima, one or more near each region of interest. Worse, they are nearly flat away from the data: with a stationary kernel, far from all observations the posterior returns to the prior, so its mean and standard deviation, and with them the acquisition function and its gradient, stop changing (Garnett, 2023, sec. 9.2). In high dimensions almost the whole domain is far from the data, so a gradient method started at a random point usually finds a gradient of nearly zero and goes nowhere.

The standard answer is multi-start local optimization, the approach recommended in Garnett's textbook (Garnett, 2023, sec. 9.2) and used by BoTorch (Balandat et al., 2020).

Algorithm 12.1 Maximizing an acquisition function by multi-start gradient ascent

Input: acquisition function ana_n with gradient, domain [0,1]d[0, 1]^d, numbers R≪MR \ll M.

  1. Screen. Evaluate ana_n at MM quasi-random points, for example the first MM points of a scrambled Sobol sequence (Section 11.4). Add points near the best observations if the acquisition function is likely to be flat elsewhere.
  2. Select. Choose RR starting points among them, favoring high values while keeping some variety.
  3. Climb. From each start, run a gradient-based local optimizer that respects the box, such as L-BFGS-B. (It is a quasi-Newton method: it estimates the curvature of ana_n from successive gradients instead of computing second derivatives.)
  4. Return the best local maximum found.

BoTorch's defaults follow this outline: the screening points come from a scrambled Sobol sequence, the starting points are drawn at random with probabilities proportional to exp⁡(ηZ)\exp(\eta Z), where ZZ is the standardized acquisition value and η\eta a temperature, and the local climbs use L-BFGS-B. The climbs are independent of one another, so they parallelize well (Garnett, 2023, sec. 9.2).

Monte Carlo versions of acquisition functions, which estimate an expectation by averaging over samples instead of using a closed form, need one more idea. Wilson et al. (2018) showed that when the samples are written as a fixed transformation of fixed random numbers, the Monte Carlo estimate is a smooth function of the input, so gradient ascent works on it too. They also identified a family of acquisition functions, including EI and UCB, whose properties justify building a batch of evaluations greedily, one point at a time, each maximized given the points already chosen. Batch selection is the subject of Section 14.3.

12.9.1 From two dimensions to twenty #

The grid in Figure 12.4 had 961 points and missed nothing. Three things change as the dimension grows to the 6 to 20 of a typical tuning problem.

Grids are out, and so is uniform screening. A grid with ten values per input has 10610^6 points in six dimensions and 102010^{20} in twenty. Uniform random or Sobol screening points do not need a grid, but they share its weakness in a different form: they land mostly far from the data, where the acquisition function is flat. A useful picture: if an evaluation informs the model within a radius of about 0.20.2, one evaluation influences 0.033% of the six-dimensional unit cube (the computation behind Section 11.3). With 60 evaluations, at most about 2% of uniformly placed screening points land within that radius of any evaluation, and the acquisition function is essentially constant at the rest.

Figure 12.5 measures this directly on Hartmann-6, a standard six-dimensional test function, hidden among irrelevant inputs when d>6d > 6.

d = 20, 50 evaluations: the best uniform candidate has EI 0.0015; the best local one 0.2 (130× larger)distance to the nearest evaluation (lengthscales)uniform in the cubenear the 5 best evaluations01234expected improvement (log scale)uniform in the cubebest 0.0015near the 5 best evaluationsbest 0.210⁻¹²10⁻⁹10⁻⁶10⁻³1
d = 20, 50 evaluations. Best EI:uniform 0.0015, local 0.2 (130× larger)distance to the nearest evaluation (lengthscales)uniform in the cubenear the 5 best evaluations01234expected improvement (log scale)uniform in the cubebest 0.0015near the 5 best evaluationsbest 0.210⁻¹²10⁻⁹10⁻⁶10⁻³1
Figure 12.5 Two ways to look for the maximum of expected improvement, in 2 to 20 dimensions. After a Latin hypercube of 10+2d10 + 2d evaluations of Hartmann-6 (for d=2d = 2, a slice through its maximum; for d>6d > 6, with d−6d - 6 irrelevant inputs added), a Gaussian process with lengthscale 0.2d0.2\sqrt{d} is fitted, and EI is computed at 1,000 points drawn uniformly from the cube (gray) and at 1,000 random perturbations, with standard deviation 0.05 per coordinate, of the five best evaluations (orange). Left: each candidate's distance to the nearest evaluation, in lengthscales. Right: the EI values on a log scale, with each set's best marked; values below 10−1210^{-12} are counted in the leftmost bin. EI is in units of the standardized observations. New draw changes the evaluations and candidates; the numbers are illustrative.

Switch from d=2d = 2 to d=20d = 20. In two dimensions the best uniform candidate is as good as the best perturbation of the data: both sets find the same peak of EI. In twenty dimensions the best of 1,000 uniform candidates has, in the default draw, an expected improvement more than a hundred times smaller than the best perturbation. The lengthscale grows with d\sqrt{d}, the rate at which Hvarfner et al. (2024) scale their lengthscale prior for high dimensions, yet the typical uniform candidate is still about 1.4 lengthscales from the nearest evaluation in twenty dimensions, against about 0.4 in two (left panel). There the posterior mean is ordinary and the incumbent is several standard deviations away. EI there is tiny and nearly constant, so the screening step of Algorithm 12.1 would start its climbs from uninformative points.

Candidates come from near the data. So practical implementations put their candidates where the acquisition function has structure. One recipe mixes a quasi-random sample of the whole cube with random perturbations of the best inputs found so far, perturbing only some coordinates at a time. TuRBO, a method for high-dimensional problems that searches inside a trust region, a box around the best point found so far (Section 14.6.2), draws its Thompson samples on candidate sets of min⁡(100d,5000)\min(100d, 5000) points built this way: each coordinate of a candidate takes a quasi-random value within the trust region with probability min⁡(1,20/d)\min(1, 20/d) and otherwise keeps the value of the region's center (Eriksson et al., 2019). The perturbation is what keeps the candidates in the informative region as dd grows. The same idea, in the form of BoTorch's option to add points sampled around the best inputs, feeds step 1 of Algorithm 12.1.

Numerical flatness becomes the default. With many dimensions and many observations, the region where expected improvement is distinguishable from zero in floating point shrinks, and plain EI hands the optimizer a function that is exactly zero with zero gradient almost everywhere. This is the regime where computing log⁡EI⁡\log \EI instead of EI⁡\EI pays off most (Ament et al., 2023).

None of this changes the statistics of the acquisition function; it changes whether we find its maximum. That matters in practice. The guarantees of Chapter 13 assume the maximization is exact (Srinivas et al., 2010), and Ament et al. (2023) found that better maximization alone changed how EI compared with newer acquisition functions. Whether a published comparison used a good inner optimizer is worth checking before trusting it (inference). Section 14.6 discusses the surrogate side of high dimensions, where the default lengthscale priors matter as much as the acquisition function.

Sources cited in Section 12.9 8
  1. Frazier (2018) A Tutorial on Bayesian Optimization
  2. Garnett (2023) Bayesian Optimization
  3. Balandat et al. (2020) BoTorch: A Framework for Efficient Monte-Carlo Bayesian Optimization
  4. Wilson et al. (2018) Maximizing Acquisition Functions for Bayesian Optimization
  5. Hvarfner et al. (2024) Vanilla Bayesian Optimization Performs Great in High Dimensions
  6. Eriksson et al. (2019) Scalable Global Optimization via Local Bayesian Optimization
  7. Ament et al. (2023) Unexpected Improvements to Expected Improvement for Bayesian Optimization
  8. Srinivas et al. (2010) Gaussian Process Optimization in the Bandit Setting: No Regret and Experimental Design

12.10 Exercises #

Exercise 12.1

Let EI⁡(δ,s)=δ Φ(δ/s)+s ϕ(δ/s)\EI(\delta, s) = \delta\,\Phi(\delta/s) + s\,\phi(\delta/s) from Equation (12.4). Show that ∂EI⁡/∂δ=Φ(δ/s)\partial \EI / \partial \delta = \Phi(\delta/s) and ∂EI⁡/∂s=ϕ(δ/s)\partial \EI / \partial s = \phi(\delta/s). Conclude that EI increases with both the mean and the standard deviation. Then compute the derivative of PI, Φ(δ/s)\Phi(\delta/s), with respect to ss, and say when it is negative.

Solution

Use ϕ′(z)=−z ϕ(z)\phi'(z) = -z\,\phi(z) and write z=δ/sz = \delta/s. For δ\delta: ∂δ[δ Φ(z)]=Φ(z)+δ ϕ(z)/s=Φ(z)+z ϕ(z)\partial_\delta[\delta\,\Phi(z)] = \Phi(z) + \delta\,\phi(z)/s = \Phi(z) + z\,\phi(z) and ∂δ[s ϕ(z)]=s ϕ′(z)/s=−z ϕ(z)\partial_\delta[s\,\phi(z)] = s\,\phi'(z)/s = -z\,\phi(z). The sum is Φ(z)\Phi(z). For ss, with ∂z/∂s=−δ/s2=−z/s\partial z / \partial s = -\delta/s^2 = -z/s: ∂s[δ Φ(z)]=−δ ϕ(z) z/s=−z2ϕ(z)\partial_s[\delta\,\Phi(z)] = -\delta\,\phi(z)\,z/s = -z^2\phi(z) and ∂s[s ϕ(z)]=ϕ(z)+s ϕ′(z)(−z/s)=ϕ(z)+z2ϕ(z)\partial_s[s\,\phi(z)] = \phi(z) + s\,\phi'(z)(-z/s) = \phi(z) + z^2\phi(z). The sum is ϕ(z)\phi(z). Both Φ\Phi and ϕ\phi are positive, so EI increases in both arguments. For PI, ∂sΦ(z)=ϕ(z) (−z/s)=−(δ/s2) ϕ(δ/s)\partial_s \Phi(z) = \phi(z)\,(-z/s) = -(\delta/s^2)\,\phi(\delta/s), which is negative exactly when δ>0\delta > 0: once the mean is above the target, PI prefers less uncertainty.

Exercise 12.2

Two inputs have independent posterior beliefs f(a)∼N(0.5,0.12)f(a) \sim \N(0.5, 0.1^2) and f(b)∼N(0.3,0.42)f(b) \sim \N(0.3, 0.4^2), and no other input can be recommended. One exact evaluation is allowed. Use Equation (12.11) to compute the knowledge gradient of evaluating bb, and show that it equals the expected improvement of bb over the value 0.50.5. Why is the knowledge gradient of evaluating aa so small, and would that still be true if aa and bb were correlated?

Solution

Evaluating bb exactly reveals f(b)f(b), so σ~(b,b)=σ(b)=0.4\tilde\sigma(b, b) = \sigma(b) = 0.4 and, by independence, σ~(a,b)=0\tilde\sigma(a, b) = 0. The new means are 0.50.5 for aa and 0.3+0.4Z0.3 + 0.4Z for bb, so KG(b)=E[max⁡(0.5,0.3+0.4Z)]−0.5=E[max⁡(0.3+0.4Z−0.5,0)]\mathrm{KG}(b) = \E[\max(0.5, 0.3 + 0.4Z)] - 0.5 = \E[\max(0.3 + 0.4Z - 0.5, 0)], the expected positive part of a Gaussian with δ=−0.2\delta = -0.2 and s=0.4s = 0.4. By Equation (12.4) this is −0.2 Φ(−0.5)+0.4 ϕ(−0.5)≈−0.2×0.3085+0.4×0.3521≈0.079-0.2\,\Phi(-0.5) + 0.4\,\phi(-0.5) \approx -0.2 \times 0.3085 + 0.4 \times 0.3521 \approx 0.079, which is EI of bb against the incumbent value 0.50.5. Evaluating aa moves only aa's mean: max⁡(0.5+0.1Z,0.3)\max(0.5 + 0.1Z, 0.3) has expectation 0.5+E[max⁡(0.3−0.5−0.1Z,0)]=0.5+E[max⁡(−0.2+0.1Z′,0)]0.5 + \E[\max(0.3 - 0.5 - 0.1Z, 0)] = 0.5 + \E[\max(-0.2 + 0.1Z', 0)] with Z′=−ZZ' = -Z, which is 0.5+(−0.2 Φ(−2)+0.1 ϕ(−2))0.5 + (-0.2\,\Phi(-2) + 0.1\,\phi(-2)), less than 0.5+0.0010.5 + 0.001. So KG(a)<0.001\mathrm{KG}(a) < 0.001: evaluating aa almost never changes the recommendation, because aa would have to fall two standard deviations below its mean to lose to bb. With a positive correlation, evaluating aa would also move bb's mean, and KG would count that; this is how KG values evaluations by their effect on the whole posterior.

Exercise 12.3

Two inputs have independent beliefs f(a)∼N(μa,sa2)f(a) \sim \N(\mu_a, s_a^2) and f(b)∼N(μb,sb2)f(b) \sim \N(\mu_b, s_b^2). Show that Thompson sampling chooses aa with probability Φ ⁣((μa−μb)/sa2+sb2)\Phi\!\left((\mu_a - \mu_b) / \sqrt{s_a^2 + s_b^2}\right), and check that this is the posterior probability that aa is the better input. What happens to this probability as both standard deviations shrink while μa>μb\mu_a > \mu_b stays fixed?

Solution

Thompson sampling draws g(a)∼N(μa,sa2)g(a) \sim \N(\mu_a, s_a^2) and g(b)∼N(μb,sb2)g(b) \sim \N(\mu_b, s_b^2) independently and chooses aa if g(a)>g(b)g(a) > g(b). The difference g(a)−g(b)g(a) - g(b) is Gaussian with mean μa−μb\mu_a - \mu_b and variance sa2+sb2s_a^2 + s_b^2, so P(g(a)>g(b))=Φ((μa−μb)/sa2+sb2)\Prob(g(a) > g(b)) = \Phi((\mu_a - \mu_b)/\sqrt{s_a^2 + s_b^2}). The same computation with ff in place of gg gives the posterior probability that f(a)>f(b)f(a) > f(b), which is Equation (12.8) for this case. As the standard deviations shrink, the argument of Φ\Phi grows without bound and the probability tends to 1: Thompson sampling stops exploring bb exactly as fast as the evidence rules it out.

Exercise 12.4

Show that maximizing μn(x)+β1/2σn(x)\mu_n(\vx) + \beta^{1/2}\sigma_n(\vx) is the same as maximizing the qq-quantile of the posterior belief about f(x)f(\vx), and find qq for β1/2=1\beta^{1/2} = 1, 22, and the value βt1/2≈6.2\beta_t^{1/2} \approx 6.2 from Section 12.4. What does the last value say about how often the theory expects the true function to exceed the band?

Solution

For a Gaussian belief with mean μ\mu and standard deviation σ\sigma, the qq-quantile is μ+Φ−1(q) σ\mu + \Phi^{-1}(q)\,\sigma. So μ+β1/2σ\mu + \beta^{1/2}\sigma is the quantile with q=Φ(β1/2)q = \Phi(\beta^{1/2}), the same qq at every input, and maximizing one maximizes the other. For β1/2=1\beta^{1/2} = 1, q≈0.841q \approx 0.841; for 22, q≈0.977q \approx 0.977; for 6.26.2, qq differs from 1 by about 3×10−103 \times 10^{-10}. The theory sets the band so wide that, with high probability, the function stays inside it at every one of the candidates and at every step simultaneously, which requires a tiny failure probability per candidate and per step. This is the union bound behind Equation (12.7) (the probability that any one of many events happens is at most the sum of their probabilities; Section 13.4.3 uses it), and it is why the schedule grows with log⁡∣X∣\log |\X| and log⁡t\log t.

Further reading #

References

  1. Ament, S., Daulton, S., Eriksson, D., Balandat, M., and Bakshy, E. (2023). Unexpected Improvements to Expected Improvement for Bayesian Optimization. Advances in Neural Information Processing Systems 36 (NeurIPS 2023). Cited in §12.3 §12.9
  2. Balandat, M., Karrer, B., Jiang, D. R., Daulton, S., Letham, B., Wilson, A. G., and Bakshy, E. (2020). BoTorch: A Framework for Efficient Monte-Carlo Bayesian Optimization. Advances in Neural Information Processing Systems 33 (NeurIPS 2020). Cited in §12.6 §12.9
  3. Brochu, E., Cora, V. M., and de Freitas, N. (2010). A Tutorial on Bayesian Optimization of Expensive Cost Functions, with Application to Active User Modeling and Hierarchical Reinforcement Learning. arXiv preprint. preprint Cited in §12.2 §12.3
  4. Chowdhury, S. R., and Gopalan, A. (2017). On Kernelized Multi-armed Bandits. International Conference on Machine Learning. Cited in §12.5
  5. Clark, C. E. (1961). The Greatest of a Finite Set of Random Variables. Operations Research. Cited in §12.6
  6. Eriksson, D., Pearce, M., Gardner, J., Turner, R. D., and Poloczek, M. (2019). Scalable Global Optimization via Local Bayesian Optimization. Advances in Neural Information Processing Systems 32 (NeurIPS 2019). Cited in §12.9
  7. Frazier, P. I. (2018). A Tutorial on Bayesian Optimization. arXiv. preprint Cited in §12.1 §12.3 §12.6 §12.7 §12.9
  8. Frazier, P. I., Powell, W. B., and Dayanik, S. (2008). A Knowledge-Gradient Policy for Sequential Information Collection. SIAM Journal on Control and Optimization. Cited in §12.6
  9. Frazier, P., Powell, W., and Dayanik, S. (2009). The Knowledge-Gradient Policy for Correlated Normal Beliefs. INFORMS Journal on Computing. Cited in §12.6
  10. Garnett, R. (2023). Bayesian Optimization. Cambridge University Press. Cited in §12.1 §12.2 §12.3 §12.7 §12.9
  11. Hennig, P., and Schuler, C. J. (2012). Entropy Search for Information-Efficient Global Optimization. Journal of Machine Learning Research. Cited in §12.7
  12. Hernández-Lobato, J. M., Hoffman, M. W., and Ghahramani, Z. (2014). Predictive Entropy Search for Efficient Global Optimization of Black-box Functions. Advances in Neural Information Processing Systems 27 (NeurIPS 2014). Cited in §12.7
  13. Hvarfner, C., Hellsten, E. O., and Nardi, L. (2024). Vanilla Bayesian Optimization Performs Great in High Dimensions. International Conference on Machine Learning. Cited in §12.9
  14. Jones, D. R. (2001). A Taxonomy of Global Optimization Methods Based on Response Surfaces. Journal of Global Optimization. Cited in §12.2
  15. Jones, D. R., Schonlau, M., and Welch, W. J. (1998). Efficient Global Optimization of Expensive Black-Box Functions. Journal of Global Optimization. Cited in §12.3
  16. Kushner, H. J. (1964). A New Method of Locating the Maximum Point of an Arbitrary Multipeak Curve in the Presence of Noise. Journal of Basic Engineering. Cited in §12.1 §12.2
  17. Močkus, J. (1975). On Bayesian Methods for Seeking the Extremum. Optimization Techniques IFIP Technical Conference. Cited in §12.3
  18. Rahimi, A., and Recht, B. (2007). Random Features for Large-Scale Kernel Machines. Advances in Neural Information Processing Systems 20 (NeurIPS 2007). Cited in §12.5
  19. Russo, D., and Van Roy, B. (2014). Learning to Optimize via Posterior Sampling. Mathematics of Operations Research. Cited in §12.5
  20. Snoek, J., Larochelle, H., and Adams, R. P. (2012). Practical Bayesian Optimization of Machine Learning Algorithms. Advances in Neural Information Processing Systems 25 (NeurIPS 2012). Cited in §12.3
  21. Srinivas, N., Krause, A., Kakade, S. M., and Seeger, M. (2010). Gaussian Process Optimization in the Bandit Setting: No Regret and Experimental Design. ICML 2010. Cited in §12.4 §12.9
  22. Thompson, W. R. (1933). On the Likelihood that One Unknown Probability Exceeds Another in View of the Evidence of Two Samples. Biometrika. Cited in §12.5
  23. Villemonteix, J., Vazquez, E., and Walter, E. (2009). An Informational Approach to the Global Optimization of Expensive-to-Evaluate Functions. Journal of Global Optimization. Cited in §12.7
  24. Wang, Z., and Jegelka, S. (2017). Max-value Entropy Search for Efficient Bayesian Optimization. Proceedings of the 34th International Conference on Machine Learning (ICML 2017). Cited in §12.7
  25. Wilson, J. T., Hutter, F., and Deisenroth, M. P. (2018). Maximizing Acquisition Functions for Bayesian Optimization. Advances in Neural Information Processing Systems 31 (NeurIPS 2018). Cited in §12.9
  26. Wilson, J. T., Borovitskiy, V., Terenin, A., Mostowski, P., and Deisenroth, M. P. (2020). Efficiently Sampling Functions from Gaussian Process Posteriors. Proceedings of the 37th International Conference on Machine Learning (ICML 2020). Cited in §12.5