Dual Focal Loss to address class imbalance in semantic segmentation

Md Sazzad Hossain, John M. Betts, Andrew P. Paplinski

Research output: Contribution to journalArticleResearchpeer-review

26 Citations (Scopus)


A common problem in pixelwise classification or semantic segmentation is class imbalance, which tends to reduce the classification accuracy of minority-class regions. An effective way to address this is to tune the loss function, particularly when Cross Entropy (CE), is used for classification. Although several CE variants have been reported in previous studies to address this problem, for example, Weighted Cross Entropy (WCE), Dual Cross Entropy (DCE), and Focal Loss (FL), each has their own limitations, such as introducing a vanishing gradient, penalizing negative classes inversely, or a sub-optimal loss weighting between classes. This limits their ability to improve classification accuracy or reduces their ease of use. Focal Loss has proven to be effective at balancing loss by increasing the loss on hard-to-classify classes. However, it tends to produce a vanishing gradient during backpropagation. To address these limitations, a Dual Focal Loss (DFL) function is proposed to improve the classification accuracy of the unbalanced classes in a dataset. The proposed loss function modifies the loss scaling method of FL to be effective against a vanishing gradient. In addition, inspired by DCE, a regularization term has also been added to DFL to constrain the negative class labels to further reduce the vanishing gradient effect and increase the loss on hard-to-classify classes. Experimental results show that DFL has better training performance, and provides greater accuracy compared to CE, WCE, FL and DCE in every test run conducted over a variety of different network models and datasets.

Original languageEnglish
Pages (from-to)69-87
Number of pages19
Publication statusPublished - 28 Oct 2021


  • Class imbalance
  • Cross entropy loss
  • Deep neural networks
  • Semantic segmentation

Cite this