V-Net: Fully Convolutional Neural Networks for Volumetric Medical Image Segmentation
What is the formula for the dice loss used in segmentation tasks?
Where and are the ground truth and predicted mask.
In PyTorch this can be implemented as:
def dice_loss(input, target):
smooth = 1.
iflat = input.view(-1)
tflat = target.view(-1)
intersection = (iflat * tflat).sum()
return 1 - ((2. * intersection + smooth) /
(iflat.sum() + tflat.sum() + smooth))