Tutorials › Statistical Learning (Graduate) › Temperature Adaptation with a Prior Over Temperatures

Exponential Weights and Convex Aggregation · Tutorial 344 of 989

Temperature Adaptation with a Prior Over Temperatures

Learn how to combine temperature-specific aggregates, quantify the cost of selecting a temperature, and identify when a finite grid can adapt to unknown loss curvature.

Advanced 12 min read

What You'll Learn

  • Define temperature-specific exponential weights using a prior over predictors
  • Prove the oracle inequality for one temperature
  • Add an outer prior-weighted mixture over candidate temperatures
  • Separate cumulative penalties from their per-round versions
  • Identify when a temperature grid can adapt to unknown curvature
  • Recognize why a prior over temperatures does not remove all curvature assumptions

Why Put a Prior on Temperature?

Exponential weighting depends on a temperature: a small temperature concentrates weights quickly on predictors with low past loss, while a large temperature changes weights more cautiously. The useful choice depends on how much curvature the loss provides. A temperature that is too small may invalidate a sharp aggregation guarantee; one that is unnecessarily large can make its oracle penalty costly.

A finite prior over candidate temperatures lets us update their weights from observed losses instead of committing to just one. The resulting guarantee pays for selecting a temperature, as well as for selecting a predictor within that temperature’s aggregate. Those are distinct costs, and both are cumulative unless explicitly divided by the sample size.

Setup and One-Temperature Aggregation

At round \(t=1,\ldots,n\), let the available predictions lie in a convex set \(\mathcal{F}\), and let \(\ell_t(f)\) denote the loss of prediction \(f\in\mathcal{F}\). Write \(L_n(f_{1:n})=\sum_{t=1}^n \ell_t(f_t)\) for the cumulative loss of a sequence of predictions. The loss may vary with \(t\). No probabilistic sampling assumption is needed for the results below.

Definition: The loss \(\ell_t\) is \(\alpha\)-exp-concave on \(\mathcal{F}\) if the function \(f\mapsto \exp\{-\alpha\ell_t(f)\}\) is concave on \(\mathcal{F}\). For a sequence of losses, this condition must hold at every round with the stated \(\alpha>0\). A temperature \(\tau\) is admissible for this curvature if \(1/\tau\leq\alpha\).

Suppose there are \(J\) candidate predictors \(f_1,\ldots,f_J\) and a prior \(q=(q_1,\ldots,q_J)\), where each \(q_j>0\) and \(\sum_j q_j=1\). At temperature \(\tau\), define the round-\(t\) weights using losses observed before round \(t\):

$$ w_{t,j}^{(\tau)} = \frac{q_j\exp\{-L_{t-1}(f_j)/\tau\}} {\sum_{r=1}^J q_r\exp\{-L_{t-1}(f_r)/\tau\}}, \qquad g_{\tau,t}=\sum_{j=1}^J w_{t,j}^{(\tau)}f_j, \qquad L_{t-1}(f_j)=\sum_{s=1}^{t-1}\ell_s(f_j). $$

The aggregate \(g_{\tau,t}\) is a convex combination, so it lies in \(\mathcal{F}\). The following guarantee explains why a temperature is useful when it is admissible.

Theorem: If every \(\ell_t\) is \(\alpha\)-exp-concave on \(\mathcal{F}\) and \(1/\tau\leq\alpha\), then $$ \sum_{t=1}^n \ell_t(g_{\tau,t}) \leq \min_{1\leq j\leq J} \left\{ \sum_{t=1}^n\ell_t(f_j)+\tau\log\frac{1}{q_j} \right\}. $$

Proof. Exp-concavity at \(\alpha\) implies exp-concavity at every \(1/\tau\leq\alpha\): the function \(\exp\{-\ell_t(f)/\tau\}\) is the concave function \(\exp\{-\alpha\ell_t(f)\}\) raised to the power \(1/(\alpha\tau)\leq1\), and the composition \(x\mapsto x^{1/(\alpha\tau)}\) is increasing and concave on the nonnegative reals. Thus, by concavity,

$$ \exp\{-\ell_t(g_{\tau,t})/\tau\} \geq \sum_{j=1}^Jw_{t,j}^{(\tau)} \exp\{-\ell_t(f_j)/\tau\}. $$

Let \(Z_t=\sum_j q_j\exp\{-L_t(f_j)/\tau\}\), with \(Z_0=1\). Substituting the weights into the right-hand side gives \(Z_t/Z_{t-1}\). Taking negative logarithms and summing over rounds therefore yields

$$ \sum_{t=1}^n\ell_t(g_{\tau,t}) \leq -\tau\log Z_n \leq \min_j\left\{L_n(f_j)+\tau\log(1/q_j)\right\}. $$

For the last inequality, \(Z_n\geq q_j\exp\{-L_n(f_j)/\tau\}\) for every \(j\). Taking negative logarithms proves the claim. \(\square\)

Worked Example: A Two-Predictor Update

Take two predictors with prior weights \(q_1=q_2=1/2\), temperature \(\tau=2\), and first-round losses \(\ell_1(f_1)=0\) and \(\ell_1(f_2)=1\). Before round one, both weights are \(1/2\). After observing that round’s losses, the weights for round two are

$$ w_{2,1}^{(2)} =\frac{(1/2)e^0}{(1/2)e^0+(1/2)e^{-1/2}} =\frac{1}{1+e^{-1/2}} \approx 0.6225, \qquad w_{2,2}^{(2)}\approx0.3775. $$

The lower-loss predictor receives more weight, but the update is not all-or-nothing. If the losses are \(1/4\)-exp-concave, then \(1/\tau=1/2\) is not admissible, so the theorem cannot be applied at \(\tau=2\). If instead they are \(1/2\)-exp-concave, the cumulative oracle penalty for either predictor is \(2\log 2\approx1.3863\). Admissibility is a condition on the loss curvature, not a consequence of the weights summing to one.

Putting a Prior on Candidate Temperatures

Choose a finite set of temperatures \(\tau_1,\ldots,\tau_K\), and a prior \(\pi=(\pi_1,\ldots,\pi_K)\) with all \(\pi_k>0\) and \(\sum_k\pi_k=1\). For each \(k\), construct its own sequence \(g_{k,t}=g_{\tau_k,t}\) using the same predictor prior \(q\). An outer exponential-weights update tracks the losses of these temperature-specific aggregates:

$$ v_{t,k} = \frac{\pi_k\exp\{-L_{t-1}(g_k)/\tau_{\mathrm{out}}\}} {\sum_{r=1}^K\pi_r\exp\{-L_{t-1}(g_r)/\tau_{\mathrm{out}}\}}, \qquad h_t=\sum_{k=1}^K v_{t,k}g_{k,t}, \qquad L_{t-1}(g_k)=\sum_{s=1}^{t-1}\ell_s(g_{k,s}). $$

Here \(\tau_{\mathrm{out}}\) is the outer temperature; it need not equal any inner temperature \(\tau_k\). The next result makes the two levels of selection explicit.

Theorem: Suppose every \(\ell_t\) is \(\alpha\)-exp-concave on \(\mathcal{F}\), and \(1/\tau_{\mathrm{out}}\leq\alpha\). Then $$ \sum_{t=1}^n\ell_t(h_t) \leq \min_{1\leq k\leq K} \left\{ \sum_{t=1}^n\ell_t(g_{k,t}) +\tau_{\mathrm{out}}\log\frac{1}{\pi_k} \right\}. $$

Proof. Apply exp-concavity to the convex combination \(h_t=\sum_k v_{t,k}g_{k,t}\). It gives \(\exp\{-\ell_t(h_t)/\tau_{\mathrm{out}}\}\geq \sum_k v_{t,k}\exp\{-\ell_t(g_{k,t})/\tau_{\mathrm{out}}\}\). Define \(A_t=\sum_k\pi_k\exp\{-L_t(g_k)/\tau_{\mathrm{out}}\}\), so \(A_0=1\). Substitution of \(v_{t,k}\) makes the right-hand side \(A_t/A_{t-1}\). Taking negative logarithms and summing gives \(\sum_t\ell_t(h_t)\leq-\tau_{\mathrm{out}}\log A_n\). Since \(A_n\geq \pi_k\exp\{-L_n(g_k)/\tau_{\mathrm{out}}\}\) for each \(k\), the stated comparison follows. \(\square\)

Combining this with the one-temperature result gives a hierarchical oracle inequality whenever \(\tau_k\) is admissible for the inner aggregation:

$$ \sum_{t=1}^n\ell_t(h_t) \leq \min_{\substack{k:\,1/\tau_k\leq\alpha\\1\leq j\leq J}} \left\{ \sum_{t=1}^n\ell_t(f_j) +\tau_k\log\frac{1}{q_j} +\tau_{\mathrm{out}}\log\frac{1}{\pi_k} \right\}. $$

The first penalty is the cost of comparing with predictor \(j\) within temperature \(k\); the second is the cost of comparing with temperature \(k\). The outer theorem alone compares with the actual loss of each \(g_k\), whether or not its inner temperature is admissible. Admissibility is needed to replace that aggregate loss by a predictor’s loss.

Worked Example: A Uniform Prior on Four Temperatures

Suppose the candidate temperatures are \(2,4,8,16\), with a uniform prior, so \(\pi_k=1/4\). If the outer temperature is \(\tau_{\mathrm{out}}=4\), the cumulative price for comparison with any one temperature is

$$ \tau_{\mathrm{out}}\log(1/\pi_k)=4\log 4\approx5.5452. $$

For \(n=100\) rounds, the corresponding per-round penalty is \(5.5452/100\approx0.05545\). It is not \(5.5452\) added to an average loss: \(5.5452\) is the cumulative penalty. To express the oracle bound per round, divide the entire cumulative inequality—including its oracle loss and both penalties—by \(100\). This distinction matters especially when comparing penalties computed on different scales.

Temperature Grids and Unknown Curvature

A prior over temperatures can avoid committing to a single inner temperature when the curvature is not known exactly, but the guarantee remains conditional on admissibility. If the loss has curvature \(\alpha\), an inner temperature is safe when \(\tau_k\geq1/\alpha\). Thus, only the safe members of the grid can be used in the hierarchical comparison. The outer temperature also needs to be safe: one sufficient condition is a known lower bound \(\alpha_{\min}>0\) on curvature and \(\tau_{\mathrm{out}}\geq1/\alpha_{\min}\).

For example, if curvature is known to lie between positive bounds \(\alpha_{\min}\) and \(\alpha_{\max}\), a grid spanning temperatures from \(1/\alpha_{\max}\) to at least \(1/\alpha_{\min}\) can include a safe choice across that range. The outer update can then compare with the safe candidate without being told in advance which one is most effective. A geometric grid is often convenient because it covers a wide range with relatively few points; its prior weights determine the selection costs \(\tau_{\mathrm{out}}\log(1/\pi_k)\).

This is adaptation to a finite set, not a free removal of curvature assumptions. If there is no known positive lower bound on curvature, a fixed outer temperature is not guaranteed to be admissible. A prior cannot repair an invalid exp-concavity condition. One may still use a method with a different guarantee, but the sharp exp-concave comparison derived here requires valid curvature for the outer update and for any inner aggregate invoked in the predictor-level bound.

Worked Example: Keeping the Cumulative and Average Bounds Separate

Suppose \(n=100\), the best dictionary predictor has cumulative loss \(40\), and a candidate temperature \(\tau_k=4\) has predictor prior mass \(q_j=0.1\). Let the temperature prior mass be \(\pi_k=0.2\), and take \(\tau_{\mathrm{out}}=4\). Assume both temperatures are admissible and the relevant losses satisfy the required curvature condition. The predictor-selection penalty is

$$ 4\log(1/0.1)=4\log 10\approx9.2103, $$

and the temperature-selection penalty is

$$ 4\log(1/0.2)=4\log 5\approx6.4378. $$

The cumulative oracle bound for this pair is therefore \(40+9.2103+6.4378=55.6481\). Dividing the whole bound by \(100\), the average loss is at most \(0.556481\); the average oracle loss is \(0.400000\), and the two average penalties are \(0.092103\) and \(0.064378\). Adding \(0.556481\) to the cumulative oracle loss \(40\) would mix scales. Conversely, adding the cumulative penalties \(9.2103+6.4378\) to the average oracle loss \(0.4\) would also mix scales.

Common Pitfall and Practical Meaning

A frequent error is to use the inner temperature-selection cost but forget that the outer mixture has its own cost. Another is to report a penalty such as \(\tau_{\mathrm{out}}\log(1/\pi_k)/n\) as though it were cumulative, then add it to a cumulative oracle loss. The safe procedure is to write the cumulative inequality first, include each penalty at its cumulative scale, and divide every term by \(n\) only when reporting average loss.

The prior also has a practical role: assigning a candidate temperature more prior mass makes it cheaper to compare against, while assigning very little mass makes that comparison more expensive. A finite grid is most useful when its range is chosen to include admissible temperatures that perform well, and when the outer temperature is itself valid. It lets the data reweight candidate temperatures online, while the oracle inequality records exactly what that flexibility costs.

Check Your Understanding

Check that you can distinguish the two levels of aggregation and the assumptions behind their guarantees.

  1. For a prior mass \(q_j\) on a predictor, what is its cumulative penalty at inner temperature \(\tau_k\)?
  2. Why does the outer update require its own admissible temperature, even if every inner aggregate has already been constructed?
  3. If a cumulative oracle bound is divided by \(n\), which terms must be divided by \(n\) as well?
  4. What condition makes an inner temperature safe when the loss is \(\alpha\)-exp-concave?
  5. Why does a prior over candidate temperatures not by itself guarantee a sharp bound when no positive lower bound on curvature is known?
Clinical Biostats