diff --git a/docs/source/losses.rst b/docs/source/losses.rst index 1dca79a1ac..b8e1e5e1ea 100644 --- a/docs/source/losses.rst +++ b/docs/source/losses.rst @@ -73,6 +73,11 @@ Segmentation Losses .. autoclass:: FocalLoss :members: +`AsymmetricUnifiedFocalLoss` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. autoclass:: AsymmetricUnifiedFocalLoss + :members: + `TverskyLoss` ~~~~~~~~~~~~~ .. autoclass:: TverskyLoss @@ -98,6 +103,11 @@ Segmentation Losses .. autoclass:: HausdorffDTLoss :members: +`LogHausdorffDTLoss` +~~~~~~~~~~~~~~~~~~~~ +.. autoclass:: LogHausdorffDTLoss + :members: + `SoftclDiceLoss` ~~~~~~~~~~~~~~~~ .. autoclass:: SoftclDiceLoss @@ -118,6 +128,23 @@ Segmentation Losses .. autoclass:: MCCLoss :members: +Classification Losses +--------------------- + +`AUCMLoss` +~~~~~~~~~~ +.. autoclass:: AUCMLoss + :members: + + +Detection Losses +---------------- + +`BoxGIoULoss` +~~~~~~~~~~~~~ +.. autoclass:: BoxGIoULoss + :members: + Registration Losses ------------------- diff --git a/monai/losses/unified_focal_loss.py b/monai/losses/unified_focal_loss.py index 34fff9221a..739c172e4a 100644 --- a/monai/losses/unified_focal_loss.py +++ b/monai/losses/unified_focal_loss.py @@ -186,7 +186,7 @@ class AsymmetricUnifiedFocalLoss(_Loss): Reimplementation of the Asymmetric Unified Focal Tversky Loss described in: - "Unified Focal Loss: Generalising Dice and Cross Entropy-based Losses to Handle Class Imbalanced Medical Image Segmentation", - Michael Yeung, Computerized Medical Imaging and Graphics + Michael Yeung, Computerized Medical Imaging and Graphics """ def __init__( @@ -234,16 +234,34 @@ def forward(self, y_pred: torch.Tensor, y_true: torch.Tensor) -> torch.Tensor: Args: y_pred : the shape should be BNH[WD], where N is the number of classes. It only supports binary segmentation. - The input should be the original logits since it will be transformed by - a sigmoid in the forward function. + The input should contain probability values in the range [0, 1], + not raw logits. The forward function does not apply a sigmoid. + y_true : the shape should be BNH[WD], where N is the number of classes. It only supports binary segmentation. + For single-channel predictions, y_true should also be + single-channel; both are expanded to two channels internally. + For two-channel predictions, when to_onehot_y=True, + y_true must contain single-channel class labels, which are + converted to one-hot format internally. + When to_onehot_y=False, y_true must have the same shape + as y_pred. + + Returns: + torch.Tensor: A scalar loss value calculated by combining + the Asymmetric Focal Loss and Asymmetric Focal Tversky Loss. Raises: - ValueError: When input and target are different shape - ValueError: When len(y_pred.shape) != 4 and len(y_pred.shape) != 5 - ValueError: When num_classes - ValueError: When the number of classes entered does not match the expected number + ValueError: If the input and target have incompatible shapes. + ValueError: If the input has neither 4 nor 5 dimensions. + AssertionError: If one-hot conversion is enabled with a + two-channel prediction and the target is not single-channel. + RuntimeError: If one-hot conversion is attempted with a + target class index outside the valid range. + ValueError: If the maximum target class index exceeds + num_classes - 1 when ignore_index is None and one-hot + conversion is not applied. + ValueError: If an unsupported reduction method is specified. """ if len(y_pred.shape) != 4 and len(y_pred.shape) != 5: raise ValueError(f"input shape must be 4 or 5, but got {y_pred.shape}")