Abstract
Loss functions are error metrics that quantify the difference between a prediction and its corresponding ground truth. Fundamentally, they define a functional landscape for traversal by gradient descent. Although numerous loss functions have been proposed to date in order to handle various machine learning problems, little attention has been given to enhancing these functions to better traverse the loss landscape. In this paper, we simultaneously and significantly mitigate two prominent problems in medical image segmentation namely: i) class imbalance between foreground and background pixels and ii) poor loss function convergence. To this end, we propose an adaptive logarithmic loss function. We compare this loss function with the existing state-of-the-art on the ISIC 2018 dataset, the nuclei segmentation dataset as well as the DRIVE retinal vessel segmentation dataset. We measure the performance of our methodology on benchmark metrics and demonstrate state-of-the-art performance. More generally, we show that our system can be used as a framework for better training of deep neural networks.
Introduction
In semantic segmentation, particularly within the medical imaging domain, models are tasked with classifying every pixel. This often results in extreme class imbalance, where the target anatomy (e.g., a lesion or vessel) occupies only a tiny fraction of the total image area. Standard loss functions like Binary Cross-Entropy (BCE) often fail in these scenarios, as the network can minimize loss by simply predicting the majority background class.
While overlap-based metrics like the Dice Loss have been introduced to address imbalance by weighting true positives more heavily, they are not without flaws. Dice Loss and its variants frequently exhibit unstable, jittery convergence and can become trapped in sub-optimal local minima before achieving a precise fit. This paper introduces the Adaptive Logarithmic Loss (ALL), designed to handle class imbalance while ensuring smoother and more effective convergence.
Methodology
The Adaptive Logarithmic Loss (ALL) is not a replacement for existing metrics but rather a mathematical wrapper that can be applied to them. In this study, the authors utilize Dice Loss ($DL$) as the base metric. ALL is defined as a piecewise function controlled by a threshold hyperparameter, $\gamma$:
- Linear Phase ($|DL| \ge \gamma$): During early training when errors are large, the function behaves linearly, mirroring standard Dice Loss to maintain stability.
- Logarithmic Phase ($|DL| < \gamma$): As the model nears convergence and the loss drops below the threshold, the function switches to a logarithmic curve: $\omega \ln(1 + \frac{|DL|}{\epsilon})$.
This design is rooted in the property that the derivative of a logarithmic function increases as its input decreases. By applying the chain rule, the gradient—and thus the penalty—actually increases as the error shrinks. This prevents the network from becoming "lazy" during the final stages of training, effectively pushing it out of "good enough" local minima to find more optimal solutions.
Experiments and Results
The authors evaluated ALL across three datasets with varying imbalance levels: ISIC 2018 (skin lesions), Data Science Bowl 2018 (cell nuclei), and DRIVE (retinal vessels). The framework consistently outperformed standard baselines including Jaccard, Dice, Tversky, and Focal losses.
- ISIC 2018: ALL achieved an 82.84% Jaccard Index, significantly higher than standard Dice Loss (71.92%).
- Nuclei Segmentation: ALL reached an 81.37% Jaccard Index, compared to the 77.82% baseline.
- DRIVE: On the most imbalanced dataset, ALL achieved a 70.96% Jaccard Index, outperforming Dice Loss at 64.71%.
Beyond raw performance metrics, the most striking result was the stability of training. While standard Dice Loss often exhibits erratic behavior across epochs, ALL provides a much smoother convergence trajectory.
Conclusion
The Adaptive Logarithmic Loss addresses the dual challenges of class imbalance and poor convergence by artificially amplifying gradients for small errors. While the function is sensitive to the threshold parameter $\gamma$, it proves highly effective at refining model performance in the late stages of training. Because the ALL framework is mathematically agnostic, it holds potential as a general-purpose wrapper for improving convergence across a wide variety of deep learning tasks beyond medical imaging.
Summary updated