= Temperature scaling
{title2=$q_k=\exp(z_k/T)/\sum_j\exp(z_j/T)$}
<Temperature scaling> is a method of <probability calibration> that divides a model's <neural network logits> by one fitted positive scalar before applying the <softmax function>. The temperature is selected after model training, using labels in a held-out <validation set> to minimize the negative <log-likelihood>. It adjusts reported <probabilities> without retraining all model weights.<On Calibration of Modern Neural Networks by Chuan Guo and others>[§4.2, Eq. (9), scalar temperature and validation negative log likelihood]{ref}
For class scores $z_1,\ldots,z_K$ and $T>0$,
$$
q_k(T)=\frac{\exp(z_k/T)}{\sum_{j=1}^K\exp(z_j/T)}.
$$
For the synthetic two-class scores $(2,0)$, the first-class <probability> is
$$
q_1(1)=\frac{e^2}{e^2+1}\simeq0.8808,\qquad
q_1(2)=\frac{e}{e+1}\simeq0.7311.
$$
The selected class remains the first while its reported confidence decreases.
The preservation of the selected class follows directly: dividing by positive $T$ preserves every score ordering and equality, and exponentiation is strictly increasing. Thus the set of classes attaining the largest score is unchanged. This concerns ordering between classes within one example; it does not assert preservation of confidence ordering between different examples.
A motivating measurement in the original study compares <reliability diagrams> for a 110-layer image-classification network. Its reported <expected calibration error> changes from $12.67\%$ before calibration to $0.96\%$ after <temperature scaling>. This is a result for that experimental setup and binned metric, not a guarantee for every classifier or input distribution.<On Calibration of Modern Neural Networks by Chuan Guo and others>[§5 and Fig. 4, CIFAR-100 ResNet-110 before/after reliability diagrams]{ref}
Use separate data for fitting the temperature and for final evaluation. One scalar can improve an overall confidence mismatch but cannot represent every class-specific or input-dependent error. The name refers to this probability transformation; no physical <temperature> is being measured.
Back to article page