A classifier can assign high softmax confidence to an input that does not resemble the data used to fit its parameters. Softmax normalizes scores across the available classes; it does not add a separate class for unfamiliar inputs. As a result, a large maximum probability is not evidence that an input belongs to the expected data distribution.
Energy-based out-of-distribution detection uses the full logit vector to produce a scalar score before a deployment policy decides whether an input looks familiar enough to accept. The score is simple to compute for an existing classifier, but its interpretation depends on the model, temperature, data regime, and threshold calibration.
Energy comes directly from the logits
For logits z_1, ..., z_K and a positive temperature T, the free-energy score commonly used for OOD detection is
E(x) = -T * log(sum_i exp(z_i(x) / T))This is the negative temperature-scaled log-sum-exp of the class logits. With T = 1, a logit vector such as
[4.0, 1.0, -1.0]has lower energy than
[0.4, 0.1, -0.1]because the first vector has substantially larger absolute logit values. The calculation uses all classes rather than only the largest softmax probability.
The sign convention matters. Under the definition above, lower energy is typically treated as stronger evidence for an in-distribution input, while higher energy is treated as more OOD-like. Some software exposes the negative of this value as an anomaly score, which reverses the threshold direction. A threshold copied between implementations is unsafe unless the score definition and sign are checked.
The expression should also be evaluated with a numerically stable log-sum-exp implementation. Computing every exponential directly can overflow for large positive logits even though the final logarithm is finite.
Softmax discards a degree of logit scale
Energy and maximum softmax probability can disagree because softmax is invariant to adding the same constant to every logit.
Consider two vectors:
a = [3.0, 1.0, 0.0]
b = [13.0, 11.0, 10.0]Their softmax distributions are identical. Every element of b is exactly ten larger than the corresponding element of a, and the common offset cancels during normalization.
Their energy scores are not identical. At T = 1,
E(b) = E(a) - 10The energy score therefore retains information about the absolute location of the logits that softmax probabilities remove.
That difference is useful only when the classifier’s logit geometry contains signal that separates familiar and shifted inputs. Energy is not a mathematical test of distribution membership. A classifier can still produce low energy for an unfamiliar input, and a difficult but valid input can receive high energy. The score creates a ranking signal whose behavior must be measured on relevant data.
Temperature changes more than score sharpness
The temperature in the energy expression is part of the score definition:
E_T(x) = -T * log(sum_i exp(z_i(x) / T))At small positive T, log-sum-exp approaches a max-like operation, so the largest logit has greater influence. At larger T, contributions from additional logits become more significant. This means changing T can alter the relative separation between inputs, not merely rescale a fixed score.
That behavior differs from scalar temperature scaling used purely for classifier calibration. In ordinary calibrated softmax classification, dividing all logits by one positive scalar preserves the argmax class. For energy-based OOD scoring, the resulting scalar itself is the quantity being compared, so a new temperature can require a new threshold and a fresh evaluation.
A deployed detector should therefore treat the tuple of model checkpoint, preprocessing, temperature, score convention, and threshold as one versioned decision rule. Changing one component can change score distributions even when top-one classifier accuracy appears stable.
A threshold turns ranking into a policy
A raw energy score does not state whether an input is OOD. A threshold supplies that operational decision. Under the lower-is-in-distribution convention, a simple rule is
accept as familiar if E(x) <= tau
flag as OOD-like if E(x) > tauThe value tau cannot be derived from the formula alone. It has to reflect the score distribution of the model and the errors the application can tolerate.
A held-out in-distribution set can characterize how often valid inputs exceed a candidate threshold. Representative shifted or outlier sets can characterize how often problematic inputs fall below it. These two error types correspond to different operational costs. A system that routes flagged requests to manual review may tolerate a different threshold from a system that rejects them outright.
Evaluation should preserve the distinction between ranking and thresholded decisions. AUROC summarizes ranking across thresholds, while false-positive rate at a specified true-positive operating point describes one region of that ranking. Neither metric selects a deployment threshold automatically. The chosen operating point still depends on the application and on which population is designated positive.
OOD is defined relative to an expected distribution
The label “out-of-distribution” has no useful operational meaning without a reference distribution. A classifier fitted on product photos may encounter new camera sensors, new product classes, unusual backgrounds, corrupt files, or synthetic images. Those shifts are different, and one energy threshold need not separate all of them equally.
This also affects test-set construction. A detector evaluated only against obviously unrelated images can look adequate while failing on near-distribution shifts that preserve texture and composition but change class semantics. Conversely, a set dominated by corrupted inputs measures sensitivity to corruption more than sensitivity to unseen semantic classes.
The relevant evaluation set should mirror the kinds of departures the surrounding system intends to flag. When several shift families matter, reporting their results separately exposes failure modes that a single pooled metric can hide.
Logit changes can invalidate a stable threshold
Energy is tied to raw classifier outputs. Retraining the final layer, changing regularization, replacing the checkpoint, or modifying preprocessing can shift logit magnitudes without an obvious corresponding change in predicted labels. A threshold calibrated on the old score distribution may then move to a different effective operating point.
The same concern applies to model compression and numeric changes. Quantization or conversion to another runtime can perturb logits. Small perturbations may be irrelevant far from the threshold but can flip decisions for inputs close to it. Comparing score distributions before and after such changes is more informative than checking only whether top-one labels match.
Monitoring the accepted-input score distribution can reveal drift in the detector’s input stream, but a shift in energy values does not identify the cause. It may reflect a population change, preprocessing change, model update, or a mixture of factors. Energy is a detector signal, not a diagnosis.
Energy-based OOD detection is most defensible when treated as a model-specific scoring mechanism with an explicit operating point. Its value comes from preserving logit information that normalized class probabilities discard; its boundary is that this information still comes from a classifier that was not given a universal representation of unfamiliarity.