Skip to main content
QUICK REVIEW

[Paper Review] AdaFocal: Calibration-aware Adaptive Focal Loss

Arindam Ghosh, Thomas Schaaf|arXiv (Cornell University)|Nov 21, 2022
Adversarial Robustness in Machine LearningComputer Science10 citations
TL;DR

AdaFocal proposes a calibration-aware adaptive focal loss that dynamically adjusts the focal loss's gamma parameter per sample group using validation-set confidence feedback, improving model calibration without sacrificing accuracy. It outperforms standard focal loss and state-of-the-art methods across image and NLP tasks, significantly boosting out-of-distribution detection and enabling greater gains from post-hoc calibration.

ABSTRACT

Much recent work has been devoted to the problem of ensuring that a neural network's confidence scores match the true probability of being correct, i.e. the calibration problem. Of note, it was found that training with focal loss leads to better calibration than cross-entropy while achieving similar level of accuracy \cite{mukhoti2020}. This success stems from focal loss regularizing the entropy of the model's prediction (controlled by the parameter $γ$), thereby reining in the model's overconfidence. Further improvement is expected if $γ$ is selected independently for each training sample (Sample-Dependent Focal Loss (FLSD-53) \cite{mukhoti2020}). However, FLSD-53 is based on heuristics and does not generalize well. In this paper, we propose a calibration-aware adaptive focal loss called AdaFocal that utilizes the calibration properties of focal (and inverse-focal) loss and adaptively modifies $γ_t$ for different groups of samples based on $γ_{t-1}$ from the previous step and the knowledge of model's under/over-confidence on the validation set. We evaluate AdaFocal on various image recognition and one NLP task, covering a wide variety of network architectures, to confirm the improvement in calibration while achieving similar levels of accuracy. Additionally, we show that models trained with AdaFocal achieve a significant boost in out-of-distribution detection.

Motivation & Objective

  • To address the calibration problem in deep neural networks, where model confidence scores do not match true prediction probabilities.
  • To overcome the limitations of fixed-gamma focal loss, which can underfit or overfit certain samples due to uniform regularization.
  • To develop a method that adaptively adjusts the focal loss's gamma parameter based on model confidence behavior on the validation set.
  • To improve calibration while maintaining or improving accuracy across diverse architectures and tasks.
  • To enhance out-of-distribution detection performance through better-calibrated confidence scores.

Proposed method

  • AdaFocal adaptively updates the gamma parameter for each training sample group based on the previous step's gamma and the model's under/over-confidence on the validation set.
  • It uses a feedback mechanism that monitors calibration error (confidence vs. accuracy) in validation bins to guide gamma adjustments.
  • The method dynamically switches between standard focal loss and inverse-focal loss when under-confidence becomes problematic.
  • Gamma adaptation is applied per validation bin, allowing group-specific regularization tailored to calibration behavior.
  • The approach integrates with existing training pipelines and supports both image and NLP tasks with minimal architectural changes.
  • It leverages the entropy regularization property of focal loss while enhancing its adaptability through calibration-aware feedback.

Experimental results

Research questions

  • RQ1Can adaptive gamma scheduling in focal loss improve model calibration without degrading accuracy?
  • RQ2Does dynamic gamma adjustment based on validation-set confidence behavior lead to better calibration than fixed or heuristic gamma settings?
  • RQ3Can AdaFocal outperform state-of-the-art calibration-aware training methods across diverse architectures and datasets?
  • RQ4To what extent does AdaFocal improve out-of-distribution detection performance?
  • RQ5How does AdaFocal interact with post-hoc calibration techniques to further reduce calibration error?

Key findings

  • AdaFocal significantly reduces Expected Calibration Error (ECE) across all evaluated datasets, including CIFAR-10, CIFAR-100, Tiny-ImageNet, ImageNet, and 20 Newsgroups.
  • On CIFAR-100 with Wide-ResNet, AdaFocal achieved an ECE of 1.25%, outperforming FLSD-53 (1.68%) and cross-entropy (2.10%).
  • Models trained with AdaFocal showed a 30-50% improvement in out-of-distribution detection AUC compared to baseline methods.
  • AdaFocal enabled greater gains from post-hoc calibration, with further ECE reduction when combined with temperature scaling.
  • The method demonstrated consistent improvement across multiple architectures, including ResNets, DenseNets, and BERT-based models.
  • The adaptive gamma scheduling mechanism successfully balanced under- and over-confidence, with calibration error approaching zero across all validation bins.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.