Dice loss is the Dice coefficient, which measures how much the predicted region and the ground-truth region overlap, subtracted from 1 to form a loss. It is used in segmentation, which labels each pixel of an image as "target or background," and it can learn without adjusting per-class weights even when the target (foreground) occupies only a tiny part of the image. Milletari et al. proposed it in 2016 together with V-Net, a network that segments the prostate in 3-D MRI volumes.
is the number of pixels (voxels in 3-D), is the foreground probability the model outputs for pixel , and is the ground truth (1 for foreground, 0 for background). takes values from 0 to 1 and equals 1 when the prediction matches the ground truth exactly.
The motivation was the class imbalance common in medical images.
- The organ of interest is a tiny part of the image: A target such as the prostate occupies only a small region of the whole scan.
- Per-pixel losses are pulled toward the background: When per-pixel cross-entropy is averaged over all pixels, the loss becomes small just by getting the overwhelming majority of background right. The paper points out that training falls into a state of "predicting only background," and the foreground is missed or only partly detected.
The figure at the top compares losses for a model that correctly predicts 0 for every background pixel and outputs probability for every foreground pixel. With only 1% foreground, the mean cross-entropy stays almost 0 even if the foreground is missed entirely. Dice loss, on the other hand, cancels the number of foreground pixels between the numerator and the denominator, so it follows the same curve regardless of the foreground ratio, and it approaches 1 when the foreground is missed.

