calibration
- class fgvc.special.calibration.ModelWithTemperature(model: Module)
A model wrapper that adds classifier calibration - temperature scaling method.
Paper: https://arxiv.org/abs/1706.04599 GitHub repository: https://github.com/gpleiss/temperature_scaling
- forward(x: Tensor, *args, **kwargs) Tensor
Apply forward pass on the model and scale output logits.
- fgvc.special.calibration.get_temperature(logits: ndarray, targs: ndarray, device: device | None = None) float
Tune the temperature parameter after training the model.
Paper: https://arxiv.org/abs/1706.04599 GitHub repository: https://github.com/gpleiss/temperature_scaling
The authors tune the temperature using the validation set. Tuning temperature is done using Cross Entropy loss (Softmax + NLL).
- Parameters:
logits – Numpy array with classifier raw predictions (before softmax).
targs – Numpy array with ground-truth targets.
device – Device to use (cpu,0,1,2,…).
- Returns:
A scalar value for scaling model logits.
- Return type:
temperature