iDAG: Invariant DAG Searching for Domain Generalization

Zenan Huang, Haobo Wang, Junbo Zhao, Nenggan ZhengICCV 2023 · DOI

Abstract

Standard machine learning models often fail when deployed in out-of-distribution (OOD) environments because they rely on spurious correlations that do not persist across domains. We present iDAG (Invariant Directed Acyclic Graph), a novel framework that reformulates Domain Generalization (DG) as an invariant causal graph searching problem. By identifying the underlying causal structure that remains stable across training environments, iDAG effectively filters out domain-specific noise and spurious factors. Our approach utilizes class-conditional prototypes for efficient graph searching and a hierarchical contrastive learning objective to align invariant features. Experimental results across multiple benchmarks, including CMNIST, PACS, and DomainNet, demonstrate that iDAG consistently outperforms state-of-the-art methods and exhibits superior stability under varying sample sizes.

Introduction

The fragility of modern deep learning models is a primary bottleneck for real-world deployment. These models are prone to capturing spurious correlations—patterns that are predictive in the training set but irrelevant to the actual task (e.g., identifying a "cow" by the presence of green grass). When the test environment shifts, these correlations break, leading to catastrophic performance drops.

Domain Generalization (DG) aims to build models that can generalize to unseen domains. The authors identify two critical types of distribution shifts:

  1. Diversity Shift: Discriminative features present during training are absent in the test set.
  2. Correlation Shift: Spurious features (like background color) dominate the training process because they provide a simpler, albeit incorrect, path to classification.

While existing DG methods often focus on simple feature alignment, they frequently ignore the global causal structure of the data. iDAG addresses this by explicitly searching for a causal graph that remains invariant across all training domains.

Methodology

The core innovation of iDAG is treating DG as a search for an invariant Directed Acyclic Graph (DAG) that represents the "true" relationships between features and labels.

Invariant DAG Searching

The framework learns an adjacency matrix $A$ representing the DAG. To maintain acyclicity during continuous optimization, the model employs the "NOTEARS" method, which minimizes the trace of the matrix exponential. This ensures the learned structure is a valid directed graph without loops.

Prototype-based Proxy and Contrastive Learning

Searching for a graph over high-dimensional raw data is computationally prohibitive. iDAG overcomes this by maintaining "class-conditional prototypes"—moving-average embeddings that represent each class within each domain. To ensure these prototypes are robust, the model integrates hierarchical contrastive learning (CL):

  • In-domain CL: Clusters samples near their respective domain-specific prototypes.
  • Cross-domain CL: Aligns invariant features in a shared latent space, helping the model distinguish universal factors from domain-specific ones.
The iDAG architecture: from feature extraction and prototype updates to the construction of a domain-invariant DAG and the application of a Total Effect Mask.

Total Effect Mask

Once the invariant DAG is established, the model identifies the causal ancestors of the label. A "Total Effect Mask" is then applied to the classifier, ensuring it only utilizes features with a direct or indirect causal effect on the target variable. This process effectively prunes away spurious noise and domain-specific factors that might otherwise mislead the model.

Experimental Results

iDAG was evaluated on several rigorous benchmarks designed to test resilience against distribution shifts, including Colored MNIST (CMNIST), PACS, OfficeHome, and the large-scale DomainNet dataset.

Performance Benchmarks

On the CMNIST dataset, which is specifically designed to induce extreme correlation shifts, iDAG achieved 71.82% accuracy, nearly matching the "Oracle" performance of 72.45% and significantly outperforming IRM (67.45%). On the PACS benchmark, iDAG reached an average accuracy of 88.8%, surpassing strong baselines such as SWAD (88.1%) and DNA (88.4%).

Robustness to Sample Size

A key advantage of the iDAG framework is its stability. As shown in the comparative analysis, iDAG maintains high performance even as the training sample size decreases, whereas standard Empirical Risk Minimization (ERM) and other DG methods show significant degradation.

Performance comparison across different sample sizes. iDAG demonstrates superior stability and lower error rates compared to existing DG methods like IRM and REx.

The Importance of Acyclicity

Ablation studies highlighted the necessity of the acyclicity constraint. On the biased CMNIST dataset, removing the acyclicity penalty caused accuracy to drop from 71.8% to 11.2%, confirming that the directed causal structure is the primary mechanism preventing the model from falling for spurious loops.

Conclusion

iDAG represents a significant shift in Domain Generalization by moving from simple feature alignment to explicit causal discovery. By leveraging invariant DAGs and prototype-based proxies, the framework provides a robust and efficient way to filter out spurious correlations. Future work may address the challenges of Markov equivalence classes in causal discovery and scaling these methods to even higher-dimensional relational structures.

Summary updated

BibTeX
@inproceedings{huang2023idag,
  author = {Zenan Huang and Haobo Wang and Junbo Zhao and Nenggan Zheng},
  title = {{iDAG: Invariant DAG Searching for Domain Generalization}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2023},
  doi = {10.1109/iccv51070.2023.01756},
}
Figure