From cae7c72dea83edf1d2c080fd40d2be3abf5c54bf Mon Sep 17 00:00:00 2001 From: sifaoso Date: Fri, 19 Dec 2025 22:33:00 +0100 Subject: [PATCH 1/2] [ADD] soft_label argument in DiceCELoss for DiceLoss computation --- monai/losses/dice.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/monai/losses/dice.py b/monai/losses/dice.py index ed88100edd..cda7765cc7 100644 --- a/monai/losses/dice.py +++ b/monai/losses/dice.py @@ -674,6 +674,7 @@ def __init__( lambda_dice: float = 1.0, lambda_ce: float = 1.0, label_smoothing: float = 0.0, + soft_label: bool = False, ) -> None: """ Args: @@ -737,6 +738,7 @@ def __init__( smooth_dr=smooth_dr, batch=batch, weight=dice_weight, + soft_label=soft_label, ) self.cross_entropy = nn.CrossEntropyLoss(weight=weight, reduction=reduction, label_smoothing=label_smoothing) self.binary_cross_entropy = nn.BCEWithLogitsLoss(pos_weight=weight, reduction=reduction) From 9e18d85daf961c3d7f92cca10e94fa2db5100787 Mon Sep 17 00:00:00 2001 From: sifaoso Date: Fri, 19 Dec 2025 22:39:54 +0100 Subject: [PATCH 2/2] [ADD] soft_label in DiceCELoss documentation --- monai/losses/dice.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/monai/losses/dice.py b/monai/losses/dice.py index cda7765cc7..36bf6b6520 100644 --- a/monai/losses/dice.py +++ b/monai/losses/dice.py @@ -716,6 +716,8 @@ def __init__( label_smoothing: a value in [0, 1] range. If > 0, the labels are smoothed by the given factor to reduce overfitting. Defaults to 0.0. + soft_label: whether the target contains non-binary values (soft labels) or not. + If True a soft label formulation of the DiceLoss will be used. """ super().__init__()