🎯  Temperature Scaling

Temperature Scaling#

A simple post-hoc method that rescales logits to calibrate probabilities.

Important

✨ AI-generated content. This page was written with the assistance of an AI language model and is provided as a learning aid. Despite careful review, it may still contain mistakes, omissions, or out-of-date information. Whether you are new to the topic, a team lead, or a senior practitioner, treat it as a starting point rather than an authoritative reference: read it critically and independently verify anything you act on (code, commands, figures, and factual claims) against official documentation and primary sources before relying on it.

What it is#

Temperature scaling is the simplest post-hoc calibration method for neural nets — it divides the logits by a single learned scalar T before the softmax, softening or sharpening the probabilities:

\[\hat{Q} = \mathrm{softmax}(\mathbf{z} / T), \quad T > 0.\]

It is a one-parameter fix applied after training.

What T does#

T = 1 leaves the model unchanged; T > 1 makes predictions less confident (softer), which corrects the overconfidence typical of modern networks; T < 1 makes them sharper. T is fit on a held-out validation set by minimizing negative log-likelihood.