DiceLoss#

class composer.loss.DiceLoss(sigmoid=False, softmax=False, squared_pred=False, jaccard=False, batch=False, ignore_absent_classes=False, reduction='mean')[source]#

Criterion that computes the dice loss between input and target.

The implementation is derived from MONAI: https://docs.monai.io/en/stable/losses.html#diceloss. For more information about the dice loss see the original paper on dice loss: https://arxiv.org/abs/1606.04797.

Parameters
  • sigmoid (bool) โ€“ If true, apply a sigmoid function to the input. Default: False

  • softmax (bool) โ€“ If true, apply a softmax function to the input. Default: False

  • squared_pred (bool) โ€“ If true, square the inputs and targets when calculating the class unions. Default: False

  • jaccard (bool) โ€“ If true, compute the jaccard index (soft IoU) instead of dice. Default: False

  • batch (bool) โ€“ If true, sum the intersection and union areas over the batch dimension before dividing the two quantities. If false, a dice loss value is computed independently for each sample in the batch before the reduction.

  • ignore_absent_classes (bool) โ€“ If true, remove classes that are not present in the target from the loss calculation. Classes not present in the target do not contribute to the gradient, but can decrease the weight of present classes, slowing optimization. This should have no effect if all classes are present in each sample. Default: 'False'

  • reduction (str) โ€“ Specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'. 'none': no reduction will be appied, 'mean': the weighted mean of the output is taken, 'sum': the output will be summed. Default: 'mean'