Abstract
Human beings can quickly adapt to environmental changes by leveraging learning experience. However, the poor ability of adapting to dynamic environments remains a major challenge for AI models. To better understand this issue, we study the problem of continual domain adaptation, where the model is presented with a labeled source domain and a sequence of unlabeled target domains. There are two major obstacles in this problem: domain shifts and catastrophic forgetting. In this work, we propose Gradient Regularized Contrastive Learning to solve the above obstacles. At the core of our method, gradient regularization plays two key roles: (1) enforces the gradient of contrastive loss not to increase the supervised training loss on the source domain, which maintains the discriminative power of learned features; (2) regularizes the gradient update on the new domain not to increase the classification loss on the old target domains, which enables the model to adapt to an in-coming target domain while preserving the performance of previously observed domains. Hence our method can jointly learn both semantically discriminative and domain-invariant features with labeled source domain and unlabeled target domains. The experiments on Digits, DomainNet and Office-Caltech benchmarks demonstrate the strong performance of our approach when compared to the state-of-the-art.
Introduction
In real-world applications, data distributions are rarely static. For instance, an autonomous vehicle trained on sunny streets (Source Domain) must sequentially adapt to rain, snow, and fog (Target Domains). Standard Domain Adaptation (DA) techniques typically focus on a one-to-one mapping, but in Continual Domain Adaptation (CDA), models face two critical challenges: Domain Shift, where models fail to generalize to new environments, and Catastrophic Forgetting, where learning a new domain overwrites knowledge of previous ones. Existing solutions often require explicit domain labels or rely on simple data replay, which frequently fails to preserve performance on the original source task.
Methodology: Gradient Regularized Contrastive Learning (GRCL)
To address these challenges, we propose GRCL, a framework that balances learning new domain-invariant features with preserving existing knowledge through two primary mechanisms:
- Contrastive Learning (InfoNCE): The model maintains a feature bank of samples from the source and previous target domains. A contrastive loss pulls new target samples toward visually similar samples in the bank, encouraging the learning of domain-invariant features.
- Gradient Regularization: Contrastive learning can sometimes be semantically "blind," potentially aligning features of different classes that share visual similarities. GRCL resolves this by imposing two constraints: the gradient of the contrastive loss must not increase the supervised classification loss on the source domain, and updates on new domains must not increase the loss on a "domain memory" buffer of past samples.
Mathematically, this is formulated as a Quadratic Program (QP). If a proposed weight update threatens performance on old domains, the algorithm projects the gradient into a "safe" direction that satisfies all constraints.
Experimental Evaluation
We evaluated GRCL on three benchmarks: Digits (a sequence of five datasets), DomainNet (345 categories across five styles), and Office-Caltech.
Key Results
- Superior Accuracy: On the complex DomainNet sequence, GRCL achieved 37.74% average accuracy, outperforming the state-of-the-art CUA (34.22%).
- Mitigating Forgetting: On the Digits benchmark, GRCL limited performance drops on old domains to just -1.0%, compared to over -11% in standard methods.
- Source Stability: Unlike other contrastive methods that "drift" away from source labels, GRCL uniquely maintains high accuracy on the original labeled source domain.
- Positive Backward Transfer: On Office-Caltech, GRCL achieved positive backward transfer, meaning learning new domains actually improved performance on previously seen ones.
Discussion and Conclusion
A critical insight from this work is that simple multi-task learning (mixing contrastive and supervised objectives) can actually degrade performance due to conflicting gradients. Gradient regularization acts as a necessary referee to resolve these conflicts. While GRCL introduces some computational overhead due to the QP solver and requires a small memory buffer, it represents a significant advancement toward AI systems capable of continuous learning in dynamic environments without losing prior expertise.
Summary updated