Sparse Invariant Risk Minimization

Xiao Zhou, Yong Lin, Weizhong Zhang, Tong ZhangICML 2022 · OpenReview

TL;DR

Sparse Invariant Risk Minimization (SparseIRM) addresses a critical flaw in standard Invariant Risk Minimization (IRM): the tendency of overparameterized models to overfit to spurious correlations. By enforcing a global sparsity constraint throughout the entire training process, SparseIRM prevents "spurious feature leakage," significantly outperforming existing methods on out-of-distribution (OOD) generalization tasks.

The Problem: Overparameterization vs. Generalization

Deep neural networks are typically trained using Empirical Risk Minimization (ERM), which assumes that training and testing data come from the same distribution. When this assumption fails due to "distributional shifts," models often rely on spurious correlations (like a specific background color associated with a digit) rather than invariant features (the shape of the digit itself).

Invariant Risk Minimization (IRM) was designed to find features that remain consistent across different environments. However, the authors identify a "trainability-generalization contradiction." To make models easy to train, we use massive, overparameterized networks. But in the IRM framework, these large models have enough capacity to "memorize" spurious features that happen to reduce loss in the training environments. This leads to a total collapse in generalization when the model encounters new environments.

The overparameterization effects on IRM. As hidden dimensions increase, IRM's test accuracy drops sharply while training accuracy rises.

The Solution: SparseIRM

To combat this, the authors propose SparseIRM, which integrates a global sparsity constraint directly into the IRM training loop.

  • Global Sparsity Constraint: Unlike prior "lottery ticket" approaches that prune a model after it has already learned spurious features, SparseIRM limits the model's "feature budget" from the start.
  • Sparsity-During-Training: By forcing the model to select only a small subset of features to minimize loss across multiple environments, the network is incentivized to prioritize invariant features. The logic is simple: invariant features are few, while spurious and random noise features are many. A sparse model literally doesn't have the room to include all the noise.
  • Optimization: To handle the discrete nature of selecting features (a binary mask), the authors use a relaxation technique involving Bernoulli random variables and the Gumbel-Softmax trick, allowing them to optimize the mask using projected Stochastic Gradient Descent (SGD).

Datasets Evaluated

The researchers evaluated SparseIRM on four benchmarks designed to test OOD generalization:

  1. ColoredMNIST: Digits are colored such that color is a strong but spurious predictor of the label in training, but not in testing.
  2. FullColoredMNIST: An extension of ColoredMNIST to 10 classes with more complex correlations.
  3. ColoredObject: Objects from MSCOCO placed on colored backgrounds.
  4. CIFARMNIST: A hybrid dataset where CIFAR-10 images are invariant features and MNIST images are spurious features.

Key Insights

  • The Budget Defense: The most important insight is that sparsity acts as a filter. If you have 10 invariant features and 1,000 spurious ones, and you limit your model to only 15 features, it is mathematically much harder for the model to achieve low loss across different environments using only a handful of the 1,000 spurious features. It must find the 10 invariant ones.
  • IRM's Failure in the "Overparameterization Region": The authors provide a theoretical proof showing that if a model is large enough, the IRM objective can be reduced to zero by relying purely on spurious features, rendering the "invariance" penalty useless.
  • Pruning Timing Matters: The paper highlights why "sparsify-after-training" (like the MRM method) fails. If a dense model has already discarded invariant features in favor of spurious ones during initial training, no amount of post-hoc pruning can bring those invariant features back.

Key Results

SparseIRM demonstrates remarkable resilience to model scaling. While standard IRM and other variants see performance plummet as the number of hidden dimensions increases, SparseIRM's performance remains stable or even improves.

Comparison of MLP on MNIST and MNISTFull. SparseIRM (blue) maintains high accuracy as hidden dimensions grow, while IRM (orange) and MRM (green) fail.
  • Performance Gaps: On the ColoredMNIST and FullColoredMNIST datasets, SparseIRM outperformed standard IRM and the sparsify-after-training baseline (MRM) by gaps of up to 40% in test accuracy.
  • ResNet-18 Success: In extremely overparameterized settings using ResNet-18 on the ColoredObject dataset, SparseIRM achieved 87.4% accuracy, nearly matching the "Oracle" (a model trained without spurious features), while standard IRM trailed at 72.5% and MRM collapsed to 58.4%.

Limitations and Future Work

  • Computational Efficiency: The current implementation uses weight-level sparsity, which is not yet optimized for speed on standard deep learning frameworks like PyTorch or TensorFlow. The authors suggest exploring more efficient training methods in the future.
  • Task Variety: While the method excels in computer vision, its applicability to Large Language Models (LLMs) and Natural Language Processing (NLP) tasks remains to be demonstrated.
  • Hyperparameter Sensitivity: Although the authors claim the method is not overly sensitive to the sparsity target, finding the optimal "budget" for different architectures and datasets is an ongoing challenge.

Summary updated

Abstract

Invariant Risk Minimization (IRM) is an emerging invariant feature extracting technique to help generalization with distributional shift. However, we find that there exists a basic and intractable ...
BibTeX
@inproceedings{zhou2022sparse,
  author = {Xiao Zhou and Yong Lin and Weizhong Zhang and Tong Zhang},
  title = {{Sparse Invariant Risk Minimization}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=-I4WqTUofI},
}
Figure