- class composer.loss.DiceLoss(sigmoid=False, softmax=False, squared_pred=False, jaccard=False, batch=False, ignore_absent_classes=False, reduction='mean')#
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.
sigmoid (bool) – If true, apply a sigmoid function to the input. Default:
softmax (bool) – If true, apply a softmax function to the input. Default:
squared_pred (bool) – If true, square the inputs and targets when calculating the class unions. Default:
jaccard (bool) – If true, compute the jaccard index (soft IoU) instead of dice. Default:
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:
reduction (str) – Specifies the reduction to apply to the output:
'none': no reduction will be appied,
'mean': the weighted mean of the output is taken,
'sum': the output will be summed. Default: