Source-linked AI summary
A survey of loss functions for semantic segmentation
Shruti Jadon
TL;DR
Semantic segmentation uses diverse loss functions for differing data and structural conditions, but evidence is needed on which objectives suit particular cases. This paper surveys 14 well-known losses, proposes log-cosh Dice loss, and evaluates them on the NBFS skull-stripping dataset. Focal Tversky achieved the highest reported Dice coefficient, while log-cosh Dice performed nearly as well and specificity remained consistent across losses.
Problem
Loss-function suitability varies with segmentation dataset properties such as distribution, skewness, and boundaries, so no single objective performs best in every use case.
Method
The paper summarizes 14 semantic-segmentation loss functions, proposes log-cosh Dice loss, and compares them using Dice Coefficient, Sensitivity, and Specificity.
Results
A Dice coefficient of 0.98 was achieved with Focal Tversky Loss, while Log-Cosh Dice Loss achieved 0.975; specificity remained consistent across loss functions.
Takeaways & Limitations
Highly imbalanced segmentation works better with focus-based losses, balanced datasets with binary cross-entropy, and mildly skewed datasets with smoothed or generalized Dice coefficients.
Abstract
from arXiv · showhide
Image Segmentation has been an active field of research as it has a wide range of applications, ranging from automated disease detection to self-driving cars. In the past five years, various papers came up with different objective loss functions used in different cases such as biased data, sparse segmentation, etc. In this paper, we have summarized some of the well-known loss functions widely used for Image Segmentation and listed out the cases where their usage can help in fast and better convergence of a model. Furthermore, we have also introduced a new log-cosh dice loss function and compared its performance on the NBFS skull-segmentation open-source data-set with widely used loss functions. We also showcased that certain loss functions perform well across all data-sets and can be taken as a good baseline choice in unknown data distribution scenarios. Our code is available at Github: https://github.com/shruti-jadon/Semantic-Segmentation-Loss-Functions.
I. INTRODUCTION
Semantic segmentation classifies image pixels to identify structures such as tumors and lesions, making loss-function choice central to model learning. The paper surveys widely used losses and introduces log-cosh Dice loss, evaluated on skull-stripping data.
- Semantic image segmentation classifies pixels into image elements and supports localization of tumors, lesions, and other findings in medical scans.
- Loss-function choice is important because objectives initiate learning, and researchers have developed domain-specific functions for different datasets.
- The paper proposes log-cosh Dice loss and compares loss functions on the NBFS skull-stripping dataset using Dice Coefficient, Sensitivity, and Specificity.
- Binary Cross-Entropy is derived from the Bernoulli distribution and is applied to semantic segmentation with two pixel-level classes.
B. Weighted Binary Cross-Entropy
Weighted and balanced cross-entropy variants address class-skewed segmentation, while focal loss reduces emphasis on easy examples to focus learning on difficult cases.
- B. Weighted Binary Cross-Entropy: Weighted Binary Cross-Entropy assigns a coefficient to positive examples and is widely used for skewed data.The β parameter can be tuned to reduce false negatives or false positives.
- B. Weighted Binary Cross-Entropy: Balanced Cross-Entropy extends weighting to both positive and negative examples.
- D. Focal Loss: Focal Loss down-weights easy examples and focuses training on hard negatives through a modulating factor, ((1 − p)t)^γ.
- D. Focal Loss: When γ = 1, Focal Loss behaves like Cross-Entropy, while α may be set using inverse class frequency or treated as a hyperparameter.
E. Dice Loss
Dice Loss adapts the Dice coefficient for segmentation optimization, but its non-convex formulation requires an edge-case safeguard to remain defined.
- E. Dice Loss: Dice Loss adapts the widely used Dice coefficient, a similarity metric between two images, for segmentation objectives.
- E. Dice Loss: Adding 1 to the numerator and denominator prevents the function from becoming undefined when y = p̂ = 0.
F. Tversky Loss
Tversky Loss generalizes Dice by weighting false positives and false negatives, while Focal Tversky further emphasizes hard examples such as small regions of interest.
- F. Tversky Loss: Tversky Index generalizes the Dice coefficient by weighting false positives and false negatives with β.
- F. Tversky Loss: When β = 1/2, the Tversky Index reduces to the regular Dice coefficient, and Tversky Loss is defined from this index.
- F. Tversky Loss: Focal Tversky Loss uses γ to learn hard examples, including small regions of interest, similarly to Focal Loss.The stated range for γ is [1,3].
H. Sensitivity Specificity Loss
This section describes loss functions that combine segmentation metrics or structural cues to address class imbalance, curve quality, and shape similarity.
- Sensitivity and specificity are widely used metrics for evaluating segmentation predictions.
- The sensitivity-specificity formulation can address class imbalance through a weighting parameter w.
- Shape-aware loss weights cross-entropy with average point-to-curve Euclidean distance around predicted and ground-truth boundaries.This incorporates segmentation shape into the loss rather than operating only at the pixel level.
- Using E_i, the network learns prediction masks similar to the training shapes.
- Combo loss combines Dice loss with modified cross-entropy as a weighted sum.Dice loss addresses class imbalance, while cross-entropy is used for curve smoothing.
K. Exponential Logarithmic Loss
Exponential Logarithmic loss combines transformed Dice and cross-entropy terms to emphasize less accurately predicted structures and support finer boundaries and data-distribution accuracy.
- Exponential Logarithmic loss focuses on less accurately predicted structures by combining Dice Loss and Cross Entropy loss.
- The loss applies exponential and logarithmic transforms to both Dice loss and cross-entropy loss.The formulation is intended to incorporate finer decision boundaries and accurate data distribution.
- Distance-map approaches can guide networks toward hard-to-segment boundary regions using a custom penalty derived from ground-truth masks.
- A constant 1 is added to avoid vanishing gradients in U-Net and V-Net architectures.
M. Hausdorff Distance Loss
Hausdorff Distance is used to track segmentation performance, while tractable Hausdorff-based losses adapt the metric through several error-aggregation constructions.
- Hausdorff Distance is a metric used by segmentation approaches to track model performance.
- Hausdorff-based loss functions make the non-convex metric tractable for optimization.
- Three variants use the maximum of all Hausdorff errors, the minimum error from placing a radius-r circular structure, or the maximum from a convolutional kernel.
- Structural Similarity Loss addresses the omission of pixel-level structural information in many semantic segmentation losses.
- Structural Similarity Loss uses a coefficient based on correlation between ground-truth and predicted maps before applying cross-entropy.
- The loss automatically abandons pixel predictions that do not show structural correlation.
O. Log-Cosh Dice Loss
The paper proposes Log-Cosh Dice Loss as a tractable, smoothed Dice-based objective, motivated by the continuous and finite behavior of log-cosh derivatives.
- O. Log-Cosh Dice Loss: Cosh(x) is defined as the average of e^x and e^-x.
- O. Log-Cosh Dice Loss: Log-Cosh Dice Loss combines the Dice coefficient’s segmentation objective with log-cosh smoothing for tractable optimization.The proposal follows a proof that the log-cosh function remains continuous and finite after first-order differentiation.
III. EXPERIMENTS
The experiments evaluate nine loss functions with a 2D U-Net on the NBFS Skull-stripping dataset, using predefined training, validation, and test splits.
- III. EXPERIMENTS: The study uses a simple 2D U-Net with 10 convolutional encoder layers and 8 transposed-convolution decoder layers.
- III. EXPERIMENTS: The NBFS Skull-stripping dataset contains 125 skull CT scans, each with 120 slices.
- III. EXPERIMENTS: The dataset is split into 60% training, 20% validation, and 20% test data, with batch size 32 and Adam learning rate 0.001.
- III. EXPERIMENTS: Experiments compare nine loss functions and evaluate them using Dice, Sensitivity, and Specificity.
1) Evaluation Metrics:
The paper evaluates segmentation outputs with Dice Coefficient, Sensitivity, and Specificity, then concludes that loss-function performance depends on dataset characteristics and task imbalance.
- 1) Evaluation Metrics:: Dice Coefficient measures overlap between ground-truth and predicted segmentation outputs.
- 1) Evaluation Metrics:: Sensitivity emphasizes True Positives, while Specificity measures the ratio of True Negatives.
- 1) Evaluation Metrics:: A Dice coefficient of 0.98 was achieved with Focal Tversky Loss, while Log-Cosh Dice Loss achieved 0.975.
- 1) Evaluation Metrics:: No single loss function performs best in every use case; highly imbalanced segmentation favors focus-based losses, while balanced data favors binary cross-entropy.