NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Jaccard Metric Losses: Optimizing the Jaccard Index with Soft Labels

Zifu Wang, Xuefei Ning, Matthew B. Blaschko

TL;DR

Researchers have introduced Jaccard Metric Losses (JMLs), a new family of loss functions for semantic segmentation that are mathematically compatible with "soft labels." This breakthrough allows models to directly optimize for the Jaccard Index (IoU) while utilizing powerful training techniques like knowledge distillation and label smoothing, resulting in significant gains in both accuracy and model calibration across diverse architectures.

What Problem Does This Paper Address?

In semantic segmentation, we evaluate models using the Jaccard Index, also known as Intersection over Union (IoU). Because the raw IoU is discrete and non-differentiable, researchers use "surrogate" losses like the Soft Jaccard Loss (SJL) to train neural networks.

However, existing IoU losses have a major flaw: they don't play well with soft labels. Soft labels are probabilistic targets used in advanced training methods like:

  • Label Smoothing: Preventing overconfidence by softening hard "one-hot" targets.
  • Knowledge Distillation (KD): Training a small "student" model to mimic the detailed probability outputs of a large "teacher" model.
  • Semi-Supervised Learning: Using model predictions on unlabeled data as targets.

The problem is that standard SJL is not minimized when a model's prediction perfectly matches a soft target. This mathematical inconsistency prevents these powerful techniques from being effectively combined with direct IoU optimization.

Methods

The authors propose Jaccard Metric Losses (JMLs). Unlike previous surrogates, JMLs are proven to be true mathematical metrics on the space of probability vectors. This means the loss is zero if and only if the prediction exactly matches the target, even if that target is a "soft" probability.

Key technical contributions include:

  • Two JML Variants: The authors derive two versions ($\Delta_{JML1}$ and $\Delta_{JML2}$) that are identical to standard SJL when using hard labels but remain valid for soft labels.
  • Boundary Label Smoothing (BLS): A novel technique that applies label smoothing only to pixels near object boundaries, where ambiguity is highest.
  • Confidence-Based Filtering: In knowledge distillation, the student ignores low-confidence teacher predictions to avoid learning from noise and to stabilize training.

Datasets

The researchers evaluated their methods across four major semantic segmentation benchmarks:

  1. Cityscapes: Urban street scenes.
  2. PASCAL VOC: General object categories.
  3. ADE20K: A large-scale dataset with 150 diverse classes.
  4. DeepGlobe Land: Satellite imagery for land cover classification.

They tested these on 13 different architectures, ranging from classic CNNs (like ResNet) to modern Vision Transformers (like SegFormer).

Key Insights and Ideas

  • Metricity is a Superpower: Because JML is a metric, it satisfies the triangle inequality. In Knowledge Distillation, this provides a theoretical guarantee: by minimizing the distance between the student and teacher, you are implicitly minimizing the upper bound of the student's error relative to the true ground truth.
  • Late-Stage Supervision: As shown in the loss curves, JML provides much stronger gradients than Cross-Entropy (CE) when the model is already close to the target. This makes it an excellent "finisher" that helps models reach higher peak performance.
Figure 1: Loss value vs. prediction with y = 0.1 (left) and y = 0.9 (right).
  • Solving the Calibration Paradox: Direct IoU optimization usually makes models "overconfident" (poorly calibrated). However, the authors found that combining JML with soft labels (like BLS or KD) actually improves calibration, offering the best of both worlds: high IoU and reliable confidence scores.

Key Results

The results show that JML is a "plug-and-play" upgrade for segmentation models:

  • Accuracy Boost: JML consistently improved mIoU by over 2% compared to standard Cross-Entropy across almost all tested models and datasets.
  • SOTA Performance: Their straightforward JML-KD approach significantly outperformed complex, state-of-the-art distillation methods like CIRKD. For example, on PASCAL VOC, a ResNet-18 student reached 75.89% mIoU, a massive jump from the 72.47% baseline.
  • Consistency: The improvements held true for both small mobile-friendly models and massive Vision Transformers.

Detailed results for Cityscapes, PASCAL VOC, and ADE20K can be seen in the tables below, where JML-based methods (highlighted in green) consistently outperform their Cross-Entropy counterparts (red).

Table 1: Results on Cityscapes Table 2: Results on PASCAL VOC Table 3: Results on ADE20K

Limitations and Future Work

  • Gradient Steepness: When target probabilities are extremely low, JML gradients can become very steep, potentially destabilizing training. The authors mitigate this by ignoring low-confidence classes during loss calculation.
  • Distributed Training: The loss behaves differently if calculated per-GPU versus across the entire dataset. The authors recommend careful tuning of batch sizes and synchronization in multi-GPU setups.
  • Future Directions: The authors suggest exploring JML for other tasks like long-tailed classification or using it as a similarity metric for feature vectors, potentially replacing standard L2 or cosine similarity.

Summary updated

BibTeX
@inproceedings{wang2023jaccard,
  author = {Zifu Wang and Xuefei Ning and Matthew B. Blaschko},
  title = {{Jaccard Metric Losses: Optimizing the Jaccard Index with Soft Labels}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=OFMPrCAMKi},
}
Figure