Causality-based Dual-Contrastive Learning Framework for Domain Generalization

Zining Chen, Weiqiu Wang, Zhicheng Zhao, Aidong Men · DOI

TL;DR

This paper introduces a novel framework for Domain Generalization (DG) that tackles the issue of domain shifts causing model confusion in contrastive learning. By using a "Dual-Contrastive Learning" approach with a "Causal Fusion Attention" module and "Similarity-based Hard-pair Mining," the method effectively learns more robust and generalizable features, outperforming existing state-of-the-art on multiple benchmarks.

What Problem Does This Paper Address?

Deep learning models often struggle when faced with data that differs from their training distribution – a phenomenon known as out-of-distribution (OOD) generalization. Domain Generalization (DG) is a specific type of OOD generalization where models are trained on multiple "source" domains and must then perform well on unseen "target" domains without any further training or adaptation. A major challenge in DG is that existing methods, while improving, often rely on complex architectures that are hard to integrate. Furthermore, contrastive learning, a popular and efficient approach for DG, can inadvertently confuse category and domain information, leading to suboptimal performance. This paper aims to address these limitations by proposing a simpler, yet more effective, contrastive learning framework that explicitly handles domain shifts and learns causal features.

Methods

The proposed framework, named Causality-based Dual-Contrastive Learning (DCL), comprises three key components:

  • Multi-View Processing: To enrich semantic information and create diverse views of an image, the authors employ Fourier transformation. They leverage the amplitude component of the Fourier spectrum as low-level domain-related information and the phase component as high-level category-related semantics. By mixing the amplitude of the original image with a perturbed version, they generate new views.
  • Causal Fusion Attention (CFA) Module: This module is designed to fuse the diverse views generated by the Multi-View Processing step. It aims to focus on "causal features" – those that are truly indicative of the category and not just spurious correlations from a specific domain. The CFA module recalibrates features from different views to generate a "sample prototype" for each image, effectively distilling the most important semantic information.
  • Dual-Contrastive Learning (DCL) Module with Similarity-based Hard-pair Mining (SHM): This is the core of the proposed approach. It extends standard contrastive learning by introducing three types of contrastive losses:
  • Feature-to-Feature (LF2F): Pulls similar features closer and pushes dissimilar ones apart.
  • Feature-to-Prototype (LF2P): Aligns image features with their corresponding sample prototype.
  • Prototype-to-Prototype (LP2P): Encourages prototypes from the same category to be closer and from different categories to be further apart. This dual contrastive approach aims to resolve category confusion by aligning features with prototypes and domain confusion by contrasting prototypes. The SHM strategy further refines this by intelligently selecting "hard pairs" (samples that are difficult to distinguish) to improve learning, especially in the presence of domain shifts. The overall loss combines a standard classification loss with the DCL loss.

Datasets

The proposed method was evaluated on three standard Domain Generalization benchmarks:

  • PACS: A dataset with significant distribution shifts across domains like Art-painting, Cartoon, Photo, and Sketch.
  • VLCS: A mixture of datasets (VOC2007, LabelMe, Caltech101, SUN09) representing more realistic transfer learning scenarios.
  • Digits-DG: A digit recognition dataset comprising MNIST, MNIST-M, SVHN, and SYN digits, where domain differences arise from backgrounds and font styles.

The paper does not introduce any new datasets.

Key Insights and Ideas

  • The power of prototypes: The paper highlights that a single "sample prototype" derived from multiple views can capture more robust semantic information than individual features, especially in the context of domain shifts.
  • Causality as a DG solution: By explicitly designing an attention mechanism to focus on "causal features," the framework aims to disentangle domain-specific artifacts from true category-relevant information.
  • Dual contrastive learning for clarity: Separating feature-to-prototype and prototype-to-prototype contrasts helps to resolve both category confusion (by aligning features to their correct prototype) and domain confusion (by aligning prototypes of the same category across domains).
  • Hard-pair mining for robustness: Strategically mining difficult sample pairs (hard pairs) is crucial for pushing the model to learn finer distinctions and become more resilient to domain variations.
  • Plug-and-play simplicity: A significant advantage is that the proposed DCL module can be integrated into existing DG frameworks without requiring complex architectural modifications or domain labels, making it highly practical.

Key Results

The proposed DCL framework achieved state-of-the-art performance on all three tested DG benchmarks:

  • On PACS, it surpassed FACT by 0.52% on average and showed a notable improvement of 2.45% on the challenging sketch domain.
  • On VLCS, it outperformed vanilla ResNet18 by 4.19% and FACT by 1.10% on average.
  • On Digits-DG, it achieved the best performance, outperforming FACT by 2.7% on the difficult SVHN domain. Ablation studies confirmed the effectiveness of each proposed module (DCL, SHM, CFA), with the full CDCL framework yielding the best results. The method also demonstrated its plug-and-play capability, improving existing methods.

Limitations and Future Work

  • Transformation operators: While Fourier transformation is effective, the authors suggest exploring other transformation operators (like Sobel Edge Operator) for generating multi-view images, noting that their current approach with CFA and DCL can be separated from the specific multi-view generation method.
  • Hyperparameter tuning: The paper mentions that SHM might drop performance by 0.13% due to random instability, suggesting that further investigation into its robustness might be needed.
  • Future work: The authors indicate that their framework can be extended to incorporate other semantic information usage for future work. The plug-and-play nature of the DCL module also opens avenues for its integration into a wider range of DG and OOD generalization tasks.

Summary updated

BibTeX
@misc{chen2023causality,
  author = {Zining Chen and Weiqiu Wang and Zhicheng Zhao and Aidong Men},
  title = {{Causality-based Dual-Contrastive Learning Framework for Domain Generalization}},
  year = {2023},
  eprint = {2301.09120},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2301.09120},
}
Figure