Utils

topolosses.losses.utils.compute_default_dice_loss(input: torch.Tensor, target: torch.Tensor, reduce_axis: List[int] | None = None, smooth: float = 1e-05) torch.Tensor[source]

Function to compute the (weighted) Dice loss with default settings for the default base loss

Parameters:
  • input (torch.Tensor) – The predicted segmentation map with shape (N, C, …), where N is batch size, C is the number of classes.

  • target (torch.Tensor) – The ground truth segmentation map with the same shape as input.

  • reduce_axis (List[int]) – The axes along which to reduce the loss computation. To decide whether to sum the intersection and union areas over the batch dimension before the dividing.

Returns:

The Dice loss as a scalar

Return type:

torch.Tensor