Environment Diversification with Multi-head Neural Network for Invariant Learning

Bo-Wei Huang, Keng-Te Liao, Chang-Sheng Kao, Shou-De Lin

TL;DR

Standard machine learning models often fail when deployed in new environments because they latch onto spurious correlations (biases) present in the training data. This paper introduces EDNIL, a framework that automatically discovers and diversifies latent training environments using a multi-head neural network. This allows for robust out-of-distribution generalization without requiring manual environment labels or delicate model initialization.

What Problem Does This Paper Address?

When training neural networks using standard Empirical Risk Minimization (ERM), we assume that the training and testing data come from the identical distribution. In the real world, this assumption frequently breaks down. Models often exploit "spurious correlations"—shortcuts in the data that happen to predict the label in the training set but fail in the wild (for example, classifying a "waterbird" based on a water background rather than the bird itself).

Invariant Risk Minimization (IRM) was introduced to solve this by finding features that are stable across multiple training "environments." However, IRM requires humans to explicitly label these environments, which is expensive, ambiguous, or often impossible. Existing unsupervised attempts to infer these environments suffer from two major flaws:

  1. Delicate Initialization: Methods like EIIL heavily depend on a perfectly timed, flawed reference model; if the initial model is slightly overfitted or underfitted, the method fails.
  2. Efficiency Bottlenecks: Methods like KerHRM rely on computationally expensive kernel methods that do not scale well to modern deep learning architectures (like ResNet or BERT).

EDNIL addresses these challenges by jointly inferring diverse environments and learning invariant features efficiently using a multi-head network structure.

Methods

EDNIL splits the task into a joint optimization loop featuring two alternating components:

  1. The Environment Inference Model ($M_{EI}$): Instead of using expensive clustering algorithms, $M_{EI}$ uses a multi-head neural network structure. An encoder maps the inputs to a variant representation space, and multiple network "heads" act as distinct environments.
  2. The Invariant Learning Model ($M_{IL}$): This model uses the environments inferred by $M_{EI}$ to train an invariant predictor via an adjusted IRM objective.
Figure 1: Concepts of EDNIL. (a) The joint learning framework of EDNIL. The environment inference model MEI, containing a variant encoder Ψ and environmental functions f e, is trained with LEI = LED + βLLI + γLIP. The invariant learning model MIL, containing an invariant predictor Φ, is trained with LIL. (b) The multi-head network structure of the environment inference model MEI.

To ensure the inferred environments are actually useful for invariant learning, the authors design a three-part loss function for $M_{EI}$:

  • Environment Diversification Loss ($L_{ED}$): Forces the different heads to maximize the discrepancy of their spurious correlations, pushing the environments to be as distinct as possible.
  • Label Independence Loss ($L_{LI}$): Prevents the model from taking a trivial shortcut, such as grouping data purely by their target labels.
  • Invariance Preserving Loss ($L_{IP}$): Uses feedback from the invariant model ($M_{IL}$) to ensure that truly stable, invariant features are excluded from being split up by the environment generator.

The underlying data generation process is motivated by a specific causal structure where invariant features determine the label, which subsequently influences the variant features.

Figure 2: The graphical model.

Datasets

The authors evaluated EDNIL across tabular, image, and text domains using five datasets:

  • Adult-Confounded: A modified version of the UCI Adult census dataset, synthetically engineered to contain strong spurious correlations with race and sex attributes.
  • CMNIST (Colored MNIST): The classic handwritten digit dataset where digit colors are highly correlated with labels during training, but the correlation is inverted during testing.
  • Waterbirds: An image dataset combining photos of land/water birds with land/water backgrounds to test background bias.
  • SNLI (Stanford Natural Language Inference): A real-world text dataset exhibiting natural linguistic hypothesis biases.
  • Synthetic Regression Dataset: A continuous-target dataset used to validate the framework beyond classification tasks.

Key Insights and Ideas

  • Multi-Head Networks as Implicit Clusterers: Instead of using traditional clustering algorithms (like Expectation-Maximization), a multi-head classification setup can naturally partition data into distinct environments by letting each head specialize in a different data bias.
  • Breaking the Initialization Trap: Unlike prior work that requires a highly specific, poorly performing ERM model to kickstart environment inference, EDNIL's joint optimization loop allows it to succeed regardless of how the initial model is configured.
  • Feedback-Driven Splitting: The inclusion of the Invariance Preserving Loss ($L_{IP}$) acts as a vital guardrail. By telling the environment generator what the invariant model has already learned, it ensures the generator only splits data based on spurious variations.

Key Results

EDNIL consistently outperformed standard ERM and state-of-the-art unsupervised environment inference methods in worst-case testing scenarios:

  • Waterbirds: On the most challenging test subgroup (waterbirds placed on land backgrounds), EDNIL achieved 78.6% accuracy, significantly outperforming ERM (72.8%) and EIIL (68.6%).
  • CMNIST: Under severe distribution shifts (0.9 color noise), EDNIL achieved 75.2% accuracy. This completely matched the performance of the "Oracle" IRM model (which had access to perfect human-labeled environments) while beating ERM (21.7%) and KerHRM (66.1%).
  • SNLI: On the misaligned text subset, EDNIL was the only unsupervised method to show clear improvement, reaching 54.5% accuracy compared to ERM's 52.6%.

Limitations and Future Work

  • Causal Assumptions: The framework assumes the data strictly follows the graphical model where $X_c \rightarrow Y \rightarrow X_v$. If real-world data contains biases that violate this specific causal structure, EDNIL's performance guarantees may degrade.
  • Regression Discretization: For continuous regression tasks, calculating the Label Independence Loss ($L_{LI}$) currently requires coarse quartile discretization of the target variable. The authors note that developing more precise mutual information estimators for continuous variables remains an open area for future work.

Summary updated

BibTeX
@inproceedings{huang2022environment,
  author = {Bo-Wei Huang and Keng-Te Liao and Chang-Sheng Kao and Shou-De Lin},
  title = {{Environment Diversification with Multi-head Neural Network for Invariant Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
  url = {https://openreview.net/forum?id=FDmIo6o09H},
}
Figure