Manuscript Offprint
arXiv:2610.06139On Impact of Loss Function on the Performance of Neural Networks in Melanoma Diagnosis
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Morgan May [0009-0006-1953-7600], Pierpaolo Dondio [0000-0001-7874-8762], and Simon Caton [0000-0001-9379-3879]
Technological University Dublin, Dublin, Ireland
Dublin City University, Dublin, Ireland
University College Dublin, Dublin, Ireland
Research Ireland Centre for Research Training in Machine Learning, ML-Labs, Dublin, Ireland
Abstract. Melanoma is the deadliest type of skin cancer, whose early diagnosis is crucial for patients' survival. Image classification using deep learning models has shown promising results for melanoma diagnosis. However, the performance of these models on the melanoma datasets such as SIIM-ISIC melanoma classification dataset is a challenge due to the class imbalance. One of the methods to deal with this challenge is using loss function modifications. In this work, we have investigated the effect of different loss functions on the performance of deep neural networks. We trained these networks using focal loss, logit-adjusted softmax cross-entropy (CE) loss, and weighted softmax CE loss, and we report different metrics for evaluating performance and uncertainty calibration. Our results suggest that focal loss delivers a good combination of performance in terms of AUC and uncertainty calibration in terms of expected calibration error (ECE) simultaneously.
Keywords: Melanoma diagnosis · image classification · imbalanced data · loss function · model performance · uncertainty calibration.
1 Introduction
Skin cancer is a common skin disease whose incidence and mortality rates have been showing yearly increases. Early diagnosis and timely treatment of skin cancer, especially for its deadliest form, malignant melanoma, remain a critical clinical issue globally . Recently, deep learning has revolutionised melanoma diagnosis by building highly accurate classification models .
Melanoma diagnosis is an imbalance classification task, where in the available clinical datasets, the number of positive samples (malignant) is outnumbered by the negative samples (benign), because of the data scarcity of malignant cases. Imbalanced data poses a challenge for generalization on minority classes and makes naive learning biased towards the majority classes . The methods to cope with this challenge can be divided into four groups : data-level, algorithmic-level, hybrid of both and ensemble learning. One of the algorithmic level approaches is loss function modifications .
Authors in [14] compared the effect of focal loss [9], weighted cross-entropy (CE) loss [16], and large margin-aware focal (LMF) loss [17] on the performance of EfficientNet-B3 on melanoma classification. They report the results with careful hyperparameter tuning and show that LMF loss delivers higher AUC compared to focal loss and weighted CE. In this work, we investigate the effect of different loss functions, including focal loss [9], logit adjusted softmax cross-entropy loss [11], and balanced softmax cross-entropy loss [15], on the performance of EfficientNet-B0, EfficientNet-B2, and EfficientNetV2-S by performing hyperparameter tuning using grid search, for each of the combinations of loss functions and models, and incorporating the evaluation of model uncertainty calibration.
Dataset. We use the SIIM-ISIC 2020 Melanoma Classification dataset [7], which is imbalanced with an imbalance ratio of about 55. We used the 33126 labeled images in the original train set for a train/validation/test split of 80/10/10.
Models. We train two EfficientNet-B0 and EfficientNet-B2 [18], and EfficientNetV2-S [19], from an improved generation of EfficientNets, designed for better parameter efficiency and faster training compared to its predecessor, EfficientNet. The models are pretrained on ImageNet.
Loss Functions. We examine three loss functions that are used for imbalanced data: Balanced softmax cross-entropy (CE) [15], focal loss [9], and logit-adjusted softmax cross-entropy loss [11].
Performance metrics. We report AUC, F1-score, and recall for model performance evaluation, and expected calibration error (ECE) [6,12] for the evaluation of confidence calibration [6].
Hyperparameter tuning. For hyperparameter tuning, we perform grid search, including the learning rate for each model, tuned from to . For each of the loss functions, we perform individual grid searches for the hyperparameters specific to each of the loss functions, such as logit-adjustment temperature for logit-adjusted softmax CE loss, chosen from , and alpha (the balancing parameter) and gamma (the focusing parameter) for focal loss, chosen from and , respectively. Balanced softmax CE does not have any specific hyperparameters to tune.
3 Results and Discussion
Table 1 summarizes the results of training the models using different loss functions on SIIM-ISIC 2020 melanoma classification task. Initial results do not suggest a strong trend across all models trained using different loss functions. How-ever, some insights can be extracted on the performance of the models trained using different loss functions.
For the bigger models, EfficientNet-B2 and EfficientNetV2-S, focal loss results in a higher AUC value compared to logit-adjusted softmax cross-entropy loss and balanced softmax cross-entropy loss, while maintaining a relatively low ECE value across all three models. This suggests that focal loss is a good choice, specially for training bigger models to have a good performance, while maintaining good confidence calibration, which is crucial for a safety critical application such as melanoma diagnosis. It can also be observed that for both EfficientNet-B0 and EfficientNet-B2, logit-adjusted softmax cross-entropy loss leads to a higher recall than focal loss and balanced softmax cross-entropy loss, while sacrificing the ECE value, which may result in overconfident predictions, which is not desirable for melanoma diagnosis as a safety-critical application.
Table 1: Performance of different models on melanoma classification trained using different loss functions
| MODEL | LOSS | AUC | F1 | Recall | ECE |
|---|---|---|---|---|---|
| EfficientNet-B0 | Focal Loss | 0.8804 | 0.581 | 0.578 | 0.0142 |
| Logit Adjusted Softmax CE | 0.8840 | 0.532 | 0.740 | 0.0390 | |
| Balanced Softmax CE | 0.8970 | 0.573 | 0.564 | 0.0212 | |
| EfficientNet-B2 | Focal Loss | 0.8909 | 0.581 | 0.585 | 0.0225 |
| Logit Adjusted Softmax CE | 0.8904 | 0.405 | 0.788 | 0.0913 | |
| Balanced Softmax CE | 0.8803 | 0.589 | 0.624 | 0.0206 | |
| EfficientNetV2-S | Focal Loss | 0.9097 | 0.555 | 0.534 | 0.0163 |
| Logit Adjusted Softmax CE | 0.9027 | 0.626 | 0.623 | 0.0187 | |
| Balanced Softmax CE | 0.8822 | 0.620 | 0.668 | 0.0213 |
4 Conclusion
This work evaluates the effect of different loss functions on the performance of imbalanced melanoma classification. The results suggest that focal loss is a good choice for training EfficientNets and EfficientNetV2 for melanoma classification, for achieving a good performance in terms of AUC, while being well-calibrated in terms of ECE, which is crucial for the safety critical application of melanoma diagnosis. It will be interesting to see the effect of a wider variety of loss functions on the performance of a broader range of models for melanoma classification, and to evaluate the effect of a combination of multiple loss functions as the objective function for training the models.
5 Acknowledgment
This publication has emanated from research conducted with the financial support of Taighde Éireann – Research Ireland under Grant number 18/CRT/6183. For the purpose of Open Access, the author has applied a CC BY public copyright license to any Author Accepted Manuscript arising from this submission.
References
-
Cao, K., Wei, C., Gaidon, A., Arechiga, N., Ma, T.: Learning imbalanced datasets with label-distribution-aware margin loss. Advances in neural information processing systems 32 (2019)
-
Cassidy, B., Kendrick, C., Brodzicki, A., Jaworek-Korjakowska, J., Yap, M.H.: Analysis of the isic image datasets: Usage, benchmarks and recommendations. Medical image analysis 75, 102305 (2022)
-
Chen, W., Yang, K., Yu, Z., Shi, Y., Chen, C.P.: A survey on imbalanced learning: latest research, applications and future directions. Artificial Intelligence Review 57(6), 137 (2024)
-
Cui, Y., Jia, M., Lin, T.Y., Song, Y., Belongie, S.: Class-balanced loss based on effective number of samples. In: Proceedings of the IEEE/CVF conference on computer vision and pattern recognition. pp. 9268–9277 (2019)
-
Esteva, A., Kuprel, B., Novoa, R.A., Ko, J., Swetter, S.M., Blau, H.M., Thrun, S.: Dermatologist-level classification of skin cancer with deep neural networks. nature 542(7639), 115–118 (2017)
-
Guo, C., Pleiss, G., Sun, Y., Weinberger, K.Q.: On calibration of modern neural networks. In: International Conference on Machine Learning. pp. 1321–1330. PMLR (2017)
-
International Skin Imaging Collaboration: Siim-isic 2020 challenge dataset (2020). https://doi.org/10.34970/2020-ds01
-
Kaur, R., GholamHosseini, H., Sinha, R., Lindén, M.: Melanoma classification using a novel deep convolutional neural network with dermoscopic images. Sensors 22(3), 1134 (2022)
-
Lin, T.Y., Goyal, P., Girshick, R., He, K., Dollár, P.: Focal loss for dense object detection. In: Proceedings of the IEEE international conference on computer vision. pp. 2980–2988 (2017)
-
Meedeniya, D., De Silva, S., Gamage, L., Isuranga, U.: Skin cancer identification utilizing deep learning: A survey. IET Image Processing 18(13), 3731–3749 (2024)
-
Menon, A.K., Jayasumana, S., Rawat, A.S., Jain, H., Veit, A., Kumar, S.: Long-tail learning via logit adjustment. In: International Conference on Learning Representations (ICLR) (2021)
-
Naeini, M.P., Cooper, G., Hauskrecht, M.: Obtaining well calibrated probabilities using bayesian binning. In: Proceedings of the AAAI Conference on Artificial Intelligence. vol. 29 (2015)
-
Naseri, H., Safaei, A.A.: Diagnosis and prognosis of melanoma from dermoscopy images using machine learning and deep learning: a systematic literature review. BMC cancer 25(1), 75 (2025)
-
Nazari, S., Garcia, R.: Going smaller: Attention-based models for automated melanoma diagnosis. Computers in Biology and Medicine 185, 109492 (2025)
-
Ren, J., Yu, C., Ma, X., Zhao, H., Yi, S., et al.: Balanced meta-softmax for long-tailed visual recognition. Advances in neural information processing systems 33, 4175–4186 (2020)
-
Ronneberger, O., Fischer, P., Brox, T.: U-net: Convolutional networks for biomedical image segmentation. In: International Conference on Medical image computing and computer-assisted intervention. pp. 234–241. Springer (2015)
-
Sadi, A.A., Chowdhury, L., Jahan, N., Rafi, M.N.S., Chowdhury, R., Khan, F.A., Mohammed, N.: Lmfloss: A hybrid loss for imbalanced medical image classification. arXiv preprint arXiv:2212.12741 (2022)
-
Tan, M., Le, Q.: Efficientnet: Rethinking model scaling for convolutional neural networks. In: International conference on machine learning. pp. 6105–6114. PMLR (2019)
-
Tan, M., Le, Q.: Efficientnetv2: Smaller models and faster training. In: International conference on machine learning. pp. 10096–10106. PMLR (2021)
-
Wang, M., Gao, X., Zhang, L.: Recent global patterns in skin cancer incidence, mortality, and prevalence. Chinese Medical Journal 138(02), 185–192 (2025)