TL;DR
This paper tackles the challenge of domain generalization (DG) by proposing a novel method, HTCL, that quantifies and leverages "domain heterogeneity" – the diversity among different data sources. By first generating an optimal set of domain labels that maximize this heterogeneity and then using these labels for contrastive learning, HTCL significantly improves model generalization to unseen domains.
What Problem Does This Paper Address?
In real-world applications, models often perform poorly when deployed in environments different from their training data. Domain generalization (DG) aims to build models that can generalize to these unseen "target domains" using only data from multiple "source domains." A common approach is to assume that data within a domain follows a similar distribution, but this can lead to models relying on spurious correlations specific to each source domain (variant features) rather than robust, generalizable features (invariant features).
The authors argue that existing DG methods often overlook the importance of domain heterogeneity, which refers to the diversity among the source domains themselves. If source domains are too similar, the model might learn a limited set of invariant features and struggle with unseen domains. While some methods attempt to re-divide data into new "domains" to improve heterogeneity, they lack a quantitative way to measure and achieve optimal heterogeneity. This paper proposes a method to address this gap by explicitly measuring and maximizing domain heterogeneity.
Methods
The core contribution is a two-stage approach called Heterogeneity-based Two-stage Contrastive Learning (HTCL).
Stage 1: Heterogeneous Dividing Pattern Generation This stage focuses on creating a new, more heterogeneous set of domain labels.
- Heterogeneity Metric: The authors propose a novel metric, $L_H$, to quantitatively measure domain heterogeneity. This metric is based on contrastive learning and aims to maximize the distance between representations of same-class samples from different newly generated domains, while minimizing the distance for same-class samples from the same new domain. This metric is applied to variant features, which are believed to be the key to heterogeneity.
- Interactive Modules: This stage uses two interactive modules that work iteratively:
- Heterogeneity Exploration Module: This module trains a feature extractor ($\phi$) using a loss function that balances classification accuracy with the proposed heterogeneity metric ($L_{var}$).
- Pattern Generation Module: This module uses the learned feature representations from the exploration module to generate new domain labels. It employs an MLP and a loss function ($L_{divide}$) that encourages diverse domain assignments and balances the number of samples per domain.
- The iterative process of these two modules aims to find the optimal domain label assignment that maximizes heterogeneity.
Stage 2: Prediction with Heterogeneous Dividing Pattern Once the optimal heterogeneous domain labels are generated, this stage trains the final model for DG.
- Invariance-Aimed Contrastive Learning: The model is trained using the generated domain labels. The loss function includes the standard classification loss, along with a contrastive loss ($L_{cont}$) and a domain alignment loss ($L_{mmd}$). The contrastive loss specifically uses pairs of samples to encourage learning invariant features by making same-class, different-domain samples closer and different-class, same-domain samples further apart.
Datasets
The proposed method was evaluated on four standard DG datasets:
- PACS: Contains images from 7 classes across 4 domains (art, cartoon, photo, sketch).
- OfficeHome: Contains images from 65 classes across 4 domains (art, clipart, product, real).
- VLCS: Contains images from 5 classes across 4 domains (VOC2007, LabelMe, Caltech101, SUN09).
- TerraIncognita: Contains photos of wild animals from 10 classes across 4 domains (L100, L38, L43, L46).
The authors note that these datasets exhibit different types of domain shifts, including style-based shifts (PACS, OfficeHome) and shifts involving spurious correlations (VLCS, TerraIncognita).
Key Insights and Ideas
- Domain Heterogeneity is Key: The paper strongly argues that the diversity among source domains (heterogeneity) is crucial for effective domain generalization, and that original domain labels might not be optimal if they lack this diversity.
- Variant Features Drive Heterogeneity: The authors pinpoint that domain heterogeneity primarily lies in the "variant features" – those that change across domains but are not essential for classification. Maximizing heterogeneity means making these variant features diverse across domains.
- Quantifying Heterogeneity: The proposal of a concrete, contrastive learning-based metric ($L_H$) to measure domain heterogeneity is a significant contribution, enabling quantitative optimization.
- Two-Stage Approach: Separating the generation of optimal domain labels (Stage 1) from the final model training (Stage 2) allows for a focused optimization of heterogeneity before leveraging it for robust generalization.
- Leveraging Generated Labels: The second stage effectively uses the newly generated, heterogeneous domain labels to guide contrastive learning, promoting the learning of invariant features.
Key Results
- State-of-the-Art Performance: HTCL achieved the best average accuracy across the tested DG datasets, outperforming several strong baselines.
- Significant Gains: On average, HTCL improved performance by 1.7% over CORAL and showed a particularly strong gain of 2.3% on the challenging TerraIncognita dataset compared to SagNet.
- Effectiveness of Heterogeneity: Ablation studies showed that dropping the heterogeneous dividing pattern generation stage led to a performance degradation of 0.4% on average, highlighting the importance of this first stage.
- Robustness: HTCL demonstrated lower standard deviations in testing accuracies compared to other methods that also generate new domain labels, indicating improved robustness.
- Improved Domain Labeling: Visualizations (t-SNE) showed that HTCL's generated domain labels lead to better separation and clustering of features compared to other methods that also re-divide domains.
Limitations and Future Work
- Dataset-Specific Heterogeneity: The authors acknowledge that if a dataset already possesses high inherent domain heterogeneity (like VLCS), the performance gains from their method might be reduced, as there's less room for improvement in pattern generation. They suggest that considering original data heterogeneity might be a future improvement.
- Hyperparameter Sensitivity: While the method is generally robust, sensitivity analysis showed that performance can vary with hyperparameter choices, though the default settings performed well.
- Future Work: The paper suggests exploring how to better handle datasets with high inherent heterogeneity and potentially integrating the two stages more closely if beneficial.
Summary updated