Papers › Calibrating Deep Neural Networks using Focal Loss

Calibrating Deep Neural Networks using Focal Loss

21 Feb 2020NeurIPS 2020 12arXiv:2002.09437archive 2025-07-28

Jishnu Mukhoti, Viveka Kulharia, Amartya Sanyal, Stuart Golodetz, Philip H. S. Torr, Puneet K. Dokania

Miscalibration - a mismatch between a model's confidence and its correctness - of Deep Neural Networks (DNNs) makes their predictions hard to rely on. Ideally, we want networks to be accurate, calibrated and confident. We show that, as opposed to the standard cross-entropy loss, focal loss [Lin et. al., 2017] allows us to learn models that are already very well calibrated. When combined with temperature scaling, whilst preserving accuracy, it yields state-of-the-art calibrated models. We provide a thorough analysis of the factors causing miscalibration, and use the insights we glean from this to justify the empirically excellent performance of focal loss. To facilitate the use of focal loss in practice, we also provide a principled approach to automatically select the hyperparameter involved in the loss function. We perform extensive experiments on a variety of computer vision and NLP datasets, and with a wide variety of network architectures, and show that our approach achieves state-of-the-art calibration without compromising on accuracy in almost all cases. Code is available at https://github.com/torrvision/focal_calibration.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2002.09437")

Code

Syntology Ran 2 of 14 code samples harvested from 2 repositories linked to this paper; 12 have no recorded run. Of those that ran: 1 ran · our draft was wrong; 1 ran · fixture could not drive it.

By repository: official repository: 13 samples from 1 repository, 1 ran; community (archive-listed): 1 sample from 1 repository, 1 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

torrvision/focal_calibration officialmentioned in papermentioned on GitHubpytorchMIT report
kclip/calibrating-bayesian-learning mentioned on GitHubpytorch report
ondrejbohdal/meta-calibration mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

14 samples harvested; 2 ran; 0 honoured the contract we drafted; 12 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · our draft was wrong
1ran · fixture could not drive it
12unverified

Licence: 0 of the 14 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

conv3x3 torrvision/focal_calibration/Net/wide_resnet.py official repository ran · our draft was wrong MIT (permissive) · 6af95ebe99af2e36 · report
conv3x3 torrvision/focal_calibration/Net/resnet_tiny_imagenet.py official repository unverified MIT (permissive) · 2ace1c98fa5f2cd5 · report
cross_entropy torrvision/focal_calibration/Losses/loss.py official repository unverified MIT (permissive) · 3f5c5480cc1592d7 · report
densenet121 torrvision/focal_calibration/Net/densenet.py official repository unverified MIT (permissive) · a8ffeb2d34427847 · report
densenet169 torrvision/focal_calibration/Net/densenet.py official repository unverified MIT (permissive) · 02ebf5964f8e25b5 · report
densenet201 torrvision/focal_calibration/Net/densenet.py official repository unverified MIT (permissive) · 82dd30049f4202d8 · report
get_gamma torrvision/focal_calibration/Losses/focal_loss_adaptive_gamma.py official repository unverified MIT (permissive) · a60d17d88a279466 · report
resnet18 torrvision/focal_calibration/Net/resnet_tiny_imagenet.py official repository unverified MIT (permissive) · f3e49ddf8b75181f · report
resnet18 torrvision/focal_calibration/Net/resnet.py official repository unverified MIT (permissive) · 98ed40c7f20ee013 · report
resnet34 torrvision/focal_calibration/Net/resnet_tiny_imagenet.py official repository unverified MIT (permissive) · 404c563a39af77bd · report
resnet34 torrvision/focal_calibration/Net/resnet.py official repository unverified MIT (permissive) · 06b853e00fa53279 · report
resnet50 torrvision/focal_calibration/Net/resnet.py official repository unverified MIT (permissive) · 56b4d12881fdcf88 · report
wide_resnet_cifar torrvision/focal_calibration/Net/wide_resnet.py official repository unverified MIT (permissive) · a7629574fc5f15e3 · report
get_logits_labels ondrejbohdal/meta-calibration/evaluate.py community (archive-listed) ran · fixture could not drive it MIT (permissive) · 193b1a3f592079ed · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Focal Loss

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections