A classifier can assign a high softmax probability to an input that does not resemble the data used to fit it. The probability vector still has to sum to one, so normalization can produce a confident-looking prediction even when every class is a poor match. An energy score provides a scalar derived from the logits before that normalization and can serve as a signal for out-of-distribution detection.
The score does not make a classifier aware of every possible unfamiliar input. Its value depends on the model, logit scale, training procedure, and data used to set a decision threshold. That makes energy-based detection an evaluation problem as much as a scoring mechanism.
Energy uses the complete logit vector
For class logits z_1, ..., z_K and temperature T > 0, a common energy definition is:
E(x) = -T * log(sum_i exp(z_i(x) / T))Lower energy is commonly associated with inputs that fit the classifier’s in-distribution data more closely. The sign convention matters: implementations that negate or otherwise transform the score must also reverse the corresponding threshold rule.
The expression uses all class logits. This differs from maximum softmax probability, which keeps only the largest normalized class probability as its final detection statistic.
For T = 1, consider two logit vectors:
A = [8, 7, 6]
B = [2, 1, 0]Softmax is invariant to adding the same constant to every logit, so these vectors produce the same softmax probabilities. Their energy values differ because the log-sum-exp term retains the common offset. A detector based only on maximum softmax probability cannot distinguish these two cases, while an energy score can.
That extra information is useful only when absolute logit levels carry a stable signal for the model being evaluated. A change in training, calibration, regularization, or model version can alter logit scale and shift the energy distribution.
Softmax removes a degree of information
Softmax converts logits to probabilities as
p_i = exp(z_i) / sum_j exp(z_j)Adding a constant c to every logit leaves every p_i unchanged. The normalization therefore discards the common logit offset. Energy does not have that invariance:
E(z + c) = E(z) - cfor T = 1, with the analogous scaled relation for general positive T.
This distinction explains a specific limitation of confidence-only detection. Maximum softmax probability measures relative separation after normalization. It does not preserve the absolute position of the logit vector. Energy combines relative class evidence with that absolute level through log-sum-exp.
The retained offset is not automatically meaningful. Neural-network logits are not probabilities and have no universal scale shared across independently trained models. Energy thresholds therefore belong to a particular model artifact and evaluation setup rather than to the class vocabulary in general.
Temperature changes score geometry
The temperature in the energy expression is not a cosmetic parameter. It changes how much the largest logits dominate log-sum-exp.
At smaller positive temperatures, differences between scaled logits become larger, so the largest terms dominate the sum more strongly. At larger temperatures, more logits contribute materially. The leading factor T also affects the resulting score scale.
A threshold selected with one temperature cannot be transferred mechanically to another. Temperature selection and threshold selection form part of the detector definition and need evaluation together.
This also separates energy scoring from post-hoc probability calibration. A temperature used to calibrate softmax probabilities has an objective tied to probability quality. A temperature used inside an out-of-distribution score is part of a detection rule. Reusing the same numeric value does not make the two objectives equivalent.
A threshold converts a score into a detector
An energy score by itself only orders or separates examples along one scalar axis. A deployed detector needs a threshold and a direction. Under the common convention where in-distribution inputs tend toward lower energy, an application might reject inputs with energy above a selected threshold.
The threshold has no distribution-independent meaning. It should be selected against a defined reference population and an explicit operating criterion. For example, a system can choose a threshold that retains a specified fraction of accepted in-distribution examples, then measure how many designated out-of-distribution examples cross that threshold.
This framing exposes a practical constraint: threshold quality depends on the reference data. If the reference set omits important modes of valid traffic, the detector can reject legitimate inputs. If the out-of-distribution evaluation set is too narrow, reported separation can overstate behavior against other forms of shift.
The detector also inherits class-conditional effects. Some valid classes may naturally occupy different energy ranges. A single global threshold can therefore produce uneven rejection rates across classes or input subgroups. Per-class inspection can reveal this even when the aggregate score distribution appears cleanly separated.
Detection metrics need both score directions
Accuracy is not enough to evaluate an out-of-distribution score because the detector operates across thresholds. Ranking metrics such as area under the receiver operating characteristic curve summarize how often one group receives a more extreme score than the other across possible thresholds.
A threshold-specific operating point answers a different question. False acceptance and false rejection rates depend on the selected threshold and on which population is treated as positive. Reports need to state the score direction and label convention so that the numbers remain interpretable.
Precision is especially sensitive to prevalence. An evaluation set with equal numbers of familiar and unfamiliar inputs can produce a precision value that does not match a deployment where unfamiliar inputs are rare. Metrics derived from ranking can still be useful, but deployment decisions need rates tied to the expected traffic mix and cost of each error type.
No single synthetic out-of-distribution set establishes broad coverage. Corrupted images, unrelated natural images, generated text, domain changes, and adversarial inputs can create very different score distributions. Evaluation should match the forms of shift that the application can plausibly encounter.
Model changes invalidate silent threshold reuse
An energy threshold is coupled to the classifier logits. Retraining the same architecture can change those logits even when top-1 accuracy stays similar. Changing the final layer, loss, regularization, label smoothing, or calibration path can also move score distributions.
That coupling makes the threshold part of the versioned inference contract. A model update should trigger a fresh comparison of in-distribution and designated out-of-distribution score distributions before the old threshold is reused.
The same caution applies to ensembles and transformed logits. Averaging probabilities, averaging logits, and averaging per-model energy scores are different operations. Log-sum-exp is nonlinear, so these combinations are not interchangeable without an explicit detector definition.
Energy scores are most useful when treated as evidence from a particular classifier rather than as a universal familiarity measure. They preserve information that softmax normalization removes, but that information becomes actionable only after its stability and separation are measured against the distributions that matter for the deployed system.