Neural Network Foundations for Vision

logits

Logits are a network's raw output scores, before they are turned into probabilities. They are unbounded real numbers (they can be negative, zero, or large positive), where a bigger logit means more evidence for this class. A softmax or sigmoid is what later squashes logits into a clean probability distribution, but the logits themselves are the unnormalized scores the final linear layer produces. Think of them as the model's tallies of evidence, not yet converted into a percentage.

In a classifier, the final fully connected layer outputs a logit vector z in R^K, one score per class; softmax then maps z to probabilities p = softmax(z). The name comes from the logit (log-odds) function, the inverse of the sigmoid: for two classes the single logit equals log(p/(1-p)). Because softmax is shift-invariant (adding a constant to every logit leaves the probabilities unchanged), only the differences between logits carry meaning; the absolute level is a free gauge.

While differences set the predicted class, the overall scale of the logits sets confidence: multiply all logits by a large factor and the softmax sharpens toward one-hot (over-confident), shrink them and it flattens toward uniform. This is exactly the temperature knob, and it is why modern networks are often poorly calibrated, their logit scale producing probabilities more extreme than the true accuracy warrants. Temperature scaling, the simplest calibration method, just divides logits by a learned scalar T after training to make the probabilities honest.

Always keep logits around: loss functions and metrics that need numerical stability operate on logits, not probabilities. Frameworks' cross-entropy and binary-cross-entropy take logits directly and apply the log-softmax or sigmoid internally with stable math, so you should not pre-apply softmax. Logits also feed knowledge distillation (a student matches a teacher's temperature-scaled logits) and energy-based out-of-distribution detection (the logsumexp of logits is an energy score used to flag inputs unlike the training data).

Pitfall: a probability of 0.99 from an uncalibrated network is not a 99 percent chance of being right; logit scale inflates confidence. If you need trustworthy probabilities (medical imaging, autonomous driving), calibrate (temperature scaling) and verify with a reliability diagram or expected calibration error.

Also called
scoresunnormalized log-probabilities對數機率