Skip to main content
QUICK REVIEW

[Paper Review] Unified Focal loss: Generalising Dice and cross entropy-based losses to handle class imbalanced medical image segmentation

Michael Yeung, Evis Sala|arXiv (Cornell University)|Feb 8, 2021
Retinal Imaging and AnalysisMedicine9 citations
TL;DR

This paper proposes Unified Focal Loss, a hierarchical framework that generalizes Dice and cross-entropy losses to better handle class imbalance in medical image segmentation. By combining focal loss principles with differentiable, adaptive weighting, it achieves consistent performance gains across five diverse, imbalanced datasets, outperforming standard and compound loss functions in both binary and multiclass tasks.

ABSTRACT

Automatic segmentation methods are an important advancement in medical image analysis. Machine learning techniques, and deep neural networks in particular, are the state-of-the-art for most medical image segmentation tasks. Issues with class imbalance pose a significant challenge in medical datasets, with lesions often occupying a considerably smaller volume relative to the background. Loss functions used in the training of deep learning algorithms differ in their robustness to class imbalance, with direct consequences for model convergence. The most commonly used loss functions for segmentation are based on either the cross entropy loss, Dice loss or a combination of the two. We propose the Unified Focal loss, a new hierarchical framework that generalises Dice and cross entropy-based losses for handling class imbalance. We evaluate our proposed loss function on five publicly available, class imbalanced medical imaging datasets: CVC-ClinicDB, Digital Retinal Images for Vessel Extraction (DRIVE), Breast Ultrasound 2017 (BUS2017), Brain Tumour Segmentation 2020 (BraTS20) and Kidney Tumour Segmentation 2019 (KiTS19). We compare our loss function performance against six Dice or cross entropy-based loss functions, across 2D binary, 3D binary and 3D multiclass segmentation tasks, demonstrating that our proposed loss function is robust to class imbalance and consistently outperforms the other loss functions. Source code is available at: https://github.com/mlyg/unified-focal-loss

Motivation & Objective

  • Address the persistent challenge of class imbalance in medical image segmentation, where lesions or organs occupy a small fraction of the image volume.
  • Overcome limitations of standard cross-entropy and Dice losses, which are sensitive to class imbalance and may lead to poor convergence or biased predictions.
  • Develop a unified, differentiable framework that generalizes both Dice and cross-entropy-based losses to improve robustness and performance under imbalance.
  • Demonstrate consistent superiority of the proposed loss across diverse medical imaging tasks, including 2D binary, 3D binary, and 3D multiclass segmentation.
  • Provide a flexible, plug-and-play loss function that can be easily integrated into existing U-Net and similar architectures without architectural changes.

Proposed method

  • Propose a hierarchical loss framework that unifies Dice and cross-entropy losses via a differentiable, adaptive weighting mechanism.
  • Introduce a generalized focal loss component that applies class-specific, dynamic weighting to down-weight easy negatives and focus on hard examples.
  • Formulate the Unified Focal Loss as a weighted sum of a modified Dice loss and a focal cross-entropy loss, with learnable or fixed hyperparameters.
  • Use a gamma (γ) parameter to control the focusing effect, with γ=0.5 used across all classes in multiclass tasks for simplicity.
  • Ensure the loss is differentiable and compatible with standard backpropagation in U-Net and similar encoder-decoder architectures.
  • Apply the loss during training of 2D and 3D segmentation networks on five public datasets, using standard U-Net and 3D U-Net architectures.

Experimental results

Research questions

  • RQ1Can a unified loss function be designed that generalizes both Dice and cross-entropy losses while being robust to class imbalance in medical image segmentation?
  • RQ2How does the Unified Focal Loss compare in performance to standard Dice, cross-entropy, and compound losses (e.g., Combo loss) across diverse, imbalanced medical imaging datasets?
  • RQ3Does the proposed loss maintain stable gradients and improve convergence in highly imbalanced scenarios, such as small tumour segmentation in large organs?
  • RQ4Can the Unified Focal Loss generalize to multiclass segmentation tasks with multiple rare classes, such as in kidney tumour segmentation?
  • RQ5Is the performance gain of the Unified Focal Loss consistent across different imaging modalities and network architectures?

Key findings

  • The Unified Focal Loss consistently outperformed six baseline loss functions—including Dice, cross-entropy, Combo loss, and Tversky loss—across all five datasets: CVC-ClinicDB, DRIVE, BUS2017, BraTS20, and KiTS19.
  • On the highly imbalanced KiTS19 dataset, the Unified Focal Loss achieved the highest DSC (Dice Similarity Coefficient) for both kidney and kidney tumour segmentation, outperforming even the Combo loss.
  • In the BraTS20 dataset, where Dice and Tversky losses failed due to unstable gradients, the Unified Focal Loss maintained stable training and achieved superior segmentation quality.
  • Qualitative results showed that segmentations produced with the Unified Focal Loss had sharper boundaries and fewer false positives/negatives compared to other losses.
  • The loss function demonstrated no significant difference in training time compared to other losses, indicating efficient computation and practical deployability.
  • Despite using a single γ value for all classes, the Unified Focal Loss still achieved better performance than other compound losses, suggesting robustness to hyperparameter configuration.

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.