A classifier can rank the correct class above every alternative yet attach probabilities that are systematically too concentrated or too diffuse. Temperature scaling addresses that mismatch after training by applying one scalar to the logits before softmax. It changes reported confidence without changing the underlying classifier parameters.
The mechanism is narrow. It does not repair incorrect class rankings, add information to the representation, or make every individual probability accurate. Its target is the relationship between confidence and observed outcomes on data representative of deployment.
One scalar changes softmax concentration
For logits z_1, ..., z_K, ordinary softmax gives
p_i = exp(z_i) / sum_j exp(z_j)Temperature scaling introduces a positive scalar T:
p_i(T) = exp(z_i / T) / sum_j exp(z_j / T)When T > 1, differences among logits shrink before softmax, so the resulting distribution becomes less concentrated. For 0 < T < 1, those differences expand and the distribution becomes more concentrated. T = 1 leaves the probabilities unchanged.
The transformation is global: the same fitted scalar is applied to every example and class. That constraint keeps the calibration layer small, but it also limits the forms of miscalibration it can represent.
Positive temperature preserves the predicted class
Dividing every logit for one example by the same positive finite scalar preserves their order. If
z_a > z_bthen
z_a / T > z_b / T for T > 0The argmax is therefore unchanged, including the set of tied maxima when logits are equal. Top-1 classification accuracy based strictly on that argmax also remains unchanged on the same examples.
This property separates calibration from decision correction. A model that ranks class B above the correct class A still ranks B above A after temperature scaling. The method can alter confidence assigned to that decision, not reverse the ranking.
Downstream systems can still behave differently if they use probability thresholds, abstention rules, expected-cost calculations, or other logic based on probability magnitude. Preserving argmax does not imply that every decision policy remains unchanged.
The temperature is fitted on held-out predictions
Temperature is normally selected after the classifier parameters are fixed. A calibration set is passed through the model to obtain logits and labels, then T is optimized against a probabilistic objective such as negative log-likelihood.
Conceptually:
T* = argmin_T sum_n -log softmax(z_n / T)[y_n]with T constrained to be positive. Implementations often optimize an unconstrained parameter that is transformed into a positive value, or otherwise enforce the domain explicitly.
The calibration set matters because T is fitted to its joint pattern of logits and outcomes. Reusing training examples can make the calibration estimate reflect data already involved in parameter fitting. Using evaluation data that will later be reported as an untouched test set also contaminates that evaluation. A separate held-out calibration split keeps those roles distinct.
Calibration quality depends on the deployment distribution
A fitted temperature summarizes a particular relationship between score scale and empirical correctness. If deployment data shifts in class prevalence, input characteristics, label policy, or error structure, that relationship can change.
Temperature scaling has no mechanism for detecting such a shift. A scalar fitted on one distribution remains merely a stored parameter at inference time. Its validity on another distribution is an empirical question rather than a mathematical guarantee.
This boundary is especially relevant when confidence drives automation. A calibrated probability on a representative validation set should not be interpreted as a permanent frequency guarantee under arbitrary input changes.
A single temperature cannot express class-specific distortions
Suppose one class is consistently overconfident while another is underconfident. A shared scalar cannot independently flatten one class and sharpen the other. It rescales every logit in the same way.
More expressive post-hoc methods can introduce class-dependent or vector-valued parameters, but extra flexibility also increases the amount of calibration data needed to estimate those parameters reliably. Temperature scaling occupies a constrained point in that design space: one degree of freedom preserves class ordering and reduces the opportunity to fit idiosyncratic calibration samples.
The same constraint means aggregate improvement can hide local residual errors. Calibration should therefore be inspected at the granularity relevant to the application, such as important classes, score ranges, or operational subgroups, when enough data exists for those estimates to be meaningful.
Calibration metrics describe different failure surfaces
Negative log-likelihood directly evaluates the probability assigned to the observed class and is commonly used to fit the temperature. Other summaries, including bin-based calibration errors, compare confidence with empirical accuracy after grouping predictions.
These quantities are not interchangeable. A bin-based metric depends on bin construction and sample counts, while negative log-likelihood is sensitive to the full probability assigned to outcomes. A temperature selected for one objective is not guaranteed to minimize another metric.
For that reason, a calibration report needs to state the metric and aggregation procedure rather than treating a single scalar score as an intrinsic property of the model.
Serving requires the same logit boundary used during fitting
At inference time, temperature scaling belongs between the classifier logits and the final softmax. Applying it to already normalized probabilities is a different transformation. Applying an additional temperature inside a serving stack that already modifies logits can also produce a different distribution from the one evaluated during calibration.
The stored temperature should therefore travel with the model version and the exact output semantics used to fit it. Changes to the classifier checkpoint, label set, logit processing, or serving pipeline can invalidate the fitted value even when the API shape remains identical.
Temperature scaling is most precise when treated as a small post-hoc component with a clear boundary: fixed classifier logits enter, one positive scalar rescales them, and calibrated softmax probabilities leave. It can correct a broad score-scale mismatch under representative conditions, but ranking errors and distribution shift remain outside that boundary.