Lovász-Softmax is a loss function that makes it possible to directly minimize IoU (the Jaccard index), the metric used to evaluate segmentation, as a training loss. Berman et al. proposed it in 2018. IoU is "overlap ÷ combined area" of the predicted and ground-truth regions, and it is not differentiable as is. Lovász-Softmax uses the "Lovász extension," which extends the IoU loss to continuous values, and computes it in a differentiable form from softmax probabilities.
The Jaccard index of class and its loss are as follows (Eqs. (3)(4) of the paper).
is the ground-truth class of each pixel and is the predicted class. The average of over classes is mIoU, the standard evaluation metric for segmentation.
The motivation is the mismatch between the training loss and the evaluation metric.
- Training uses cross-entropy, evaluation uses IoU: Per-pixel cross-entropy is pulled toward large objects and background, which contain many pixels. IoU, by contrast, measures the overlap ratio per class, so small objects are weighted the same as large ones. The paper points out that the cross-entropy value on validation data is not a very reliable indicator of segmentation quality.
- IoU cannot be used for training as is: IoU is determined by a set, namely "which pixels were wrong," so small changes to the prediction change its value only in discrete jumps, and no gradient is available.
The left side of the figure at the top shows the computation flow, and the right side computes the Lovász extension for a 6-pixel example. The pixel errors are sorted in decreasing order, and the weighted sum of the errors is taken, where each weight is how much the Jaccard loss increases (the increment ) when the pixels are counted as "wrong" one at a time from the top.
As an analogy, it is like re-grading a test not by "the total number of correct answers" but by weighting each question according to "how much it lowers the final grade (IoU)."

