PythiloLesson 5 of 12 · progress kept in this browser

Practice in Lab: Select temperature on a held-out calibration split →

Select temperature on a held-out calibration split

Temperature scaling changes confidence without changing the within-row ordering of classes. It must be fitted using held-out labels because minimizing calibration loss is itself model selection. A fixed candidate grid makes the selection inspectable and deterministic. Large logits still need stable log-sum-exp after scaling. The demonstration compares two temperatures on the same score difference; the project later separates selection from final evaluation. This local optimizer does not imply that calibrated probabilities will survive deployment drift.

import math
for temperature in [1., 2.]:
    gap = 4/temperature
    wrong_class_loss = math.log1p(math.exp(gap))
    print(temperature, round(wrong_class_loss, 4))
Your task

Evaluate stable mean multiclass log loss for each distinct positive finite temperature in grid. Divide logits by temperature; choose minimum loss with smaller temperature breaking exact ties. Return temperature and loss. Require aligned nonempty rectangular finite logits with >=2 classes and integer target identities. These inputs are calibration data, never training or final test labels.