SGD with Hardness Weighted Sampling for Distributionally Robust Deep Learning

Lucas Fidon, Sébastien Ourselin, Tom VercauterenarXiv 2020 · DOI · OpenReview

TL;DR

This paper introduces a novel optimization method, "SGD with Hardness Weighted Sampling," that makes Distributionally Robust Optimization (DRO) practical for deep learning. This approach improves model robustness to data imbalances and variations, crucial for safety-critical applications like medical imaging, without sacrificing computational efficiency.

What Problem Does This Paper Address?

Machine learning models, especially deep neural networks, often perform poorly on underrepresented data subsets, a phenomenon known as "hidden stratification." This is particularly problematic in safety-critical domains like medical imaging, where failures can have severe consequences. While Distributionally Robust Optimization (DRO) offers a theoretical solution by optimizing for the worst-case data distribution, its practical application in deep learning has been hindered by inefficient optimization methods compared to standard Stochastic Gradient Descent (SGD). Existing DRO optimizers often introduce extra hyperparameters and computational overhead, making them difficult to integrate into existing deep learning pipelines.

Methods

The core contribution is SGD with Hardness Weighted Sampling. This method adapts standard SGD to perform DRO by intelligently sampling training data. Instead of uniformly sampling mini-batches, it assigns higher probabilities to "harder" examples – those that currently yield higher loss values. This is achieved by:

  • Hardness Weighted Sampling: A principled sampling strategy that dynamically weights training examples based on their current loss. This is inspired by Hard Example Mining but formally integrated into the DRO framework.
  • Stale Per-Example Loss Vector: To maintain computational efficiency, the method uses a history of per-example losses rather than recomputing all losses at each step. This is a practical approximation that still allows for effective hardness weighting.
  • Theoretical Guarantees: The authors provide theoretical convergence proofs for their method, extending existing work on SGD for over-parameterized deep neural networks with ReLU activations to the DRO setting. This is a significant theoretical advancement, being the first convergence result for DRO in this context.

Datasets

The paper evaluates their method on several datasets:

  • MNIST: Used as a toy example to demonstrate the benefits of DRO in a class-imbalanced scenario.
  • Fetal Brain 3D MRI Segmentation: Utilized the FeTA dataset and a private dataset, comprising a total of 437 MRIs with various anatomical variations and pathologies.
  • Brain Tumor Segmentation: Employed the BraTS 2019 dataset, a standard benchmark for brain tumor segmentation.

Key Insights and Ideas

  • Bridging DRO and Hard Example Mining: The paper demonstrates that their hardness weighted sampling approach can be viewed as a principled form of Hard Example Mining, providing a theoretical foundation for heuristic methods.
  • Practical DRO for Deep Learning: The proposed method is computationally as efficient as standard SGD, making DRO a viable option for deep learning without significant overhead.
  • Robustness to Anatomical and Protocol Variations: The experiments show that DRO significantly improves robustness in medical image segmentation, particularly for cases with anatomical abnormalities (fetal brain) and variations in imaging protocols (brain tumors).
  • Beyond Average Performance: The work highlights that focusing on average performance (ERM) can mask failures on critical subgroups. DRO, by considering worst-case scenarios, leads to more reliable models.

Key Results

  • MNIST: DRO with hardness weighted sampling achieved over 15% higher accuracy on the underrepresented digit '3' compared to ERM.
  • Fetal Brain Segmentation: nnU-Net trained with DRO showed improved segmentation for pathological cases (spina bifida, other abnormalities) by achieving comparable or higher mean Dice scores and lower interquartile ranges (IQR), indicating better robustness. For instance, improvements of up to +1pp for white matter and +1pp for cerebellum in spina bifida cases were observed.
  • Brain Tumor Segmentation: DRO improved robustness by reducing the IQR for enhancing tumor and tumor core segmentation by approximately 2pp. It also led to a more "fair" model by reducing poor segmentations on cases from specific acquisition centers (TCIA).
  • Computational Efficiency: The overhead of the hardness weighted sampler was found to be negligible, even for datasets with up to 1 million samples.

Limitations and Future Work

  • No Guarantee of Absolute Robustness: The authors acknowledge that DRO, while improving robustness, does not provide an absolute guarantee against failures, especially for subgroups entirely unrepresented in the training data.
  • Future Work: The paper suggests investigating DRO for subgroups not present in the training data as a direction for future research. They also explore the impact of importance sampling and the choice of the hyperparameter $\beta$.

Summary updated

Abstract

Limiting failures of machine learning systems is of paramount importance for safety-critical applications. In order to improve the robustness of machine learning systems, Distributionally Robust Optimization (DRO) has been proposed as a generalization of Empirical Risk Minimization (ERM). However, its use in deep learning has been severely restricted due to the relative inefficiency of the optimizers available for DRO in comparison to the wide-spread variants of Stochastic Gradient Descent (SGD) optimizers for ERM. We propose SGD with hardness weighted sampling, a principled and efficient optimization method for DRO in machine learning that is particularly suited in the context of deep learning. Similar to a hard example mining strategy in practice, the proposed algorithm is straightforward to implement and computationally as efficient as SGD-based optimizers used for deep learning, requiring minimal overhead computation. In contrast to typical ad hoc hard mining approaches, we prove the convergence of our DRO algorithm for over-parameterized deep learning networks with ReLU activation and a finite number of layers and parameters. Our experiments on fetal brain 3D MRI segmentation and brain tumor segmentation in MRI demonstrate the feasibility and the usefulness of our approach. Using our hardness weighted sampling for training a state-of-the-art deep learning pipeline leads to improved robustness to anatomical variabilities in automatic fetal brain 3D MRI segmentation using deep learning and to improved robustness to the image protocol variations in brain tumor segmentation. Our code is available at https://github.com/LucasFidon/HardnessWeightedSampler.
BibTeX
@misc{fidon2020sgd,
  author = {Lucas Fidon and Sébastien Ourselin and Tom Vercauteren},
  title = {{SGD with Hardness Weighted Sampling for Distributionally Robust Deep Learning}},
  year = {2020},
  eprint = {2001.02658},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2001.02658},
}
Figure