Gradient Regularized Contrastive Learning for Continual Domain Adaptation

Shixiang Tang, Peng Su, Dapeng Chen, Wanli Ouyang

Introduction

Continual Domain Adaptation (CDA) is a critical challenge in machine learning where a model must sequentially adapt to new, unlabeled environments while maintaining performance on the original source domain and previously encountered targets. This scenario is common in real-world applications like autonomous driving, where environmental conditions (e.g., weather, lighting) change over time. Two primary obstacles hinder effective CDA: domain shift, where statistical distributions vary across environments, and catastrophic forgetting, where learning new information overwrites previously acquired knowledge.

The GRCL Framework

To address these challenges, we introduce Gradient Regularized Contrastive Learning (GRCL). Unlike traditional multitask learning approaches that minimize a joint loss—often allowing performance on individual domains to degrade—GRCL enforces strict constraints at the gradient level to guarantee stability and prevent forgetting.

Unified Contrastive Learning

The core of GRCL is a unified contrastive loss designed to align feature distributions across domains. The model maintains a Feature Bank, updated via a momentum mechanism, which stores representations from the source domain, an episodic memory of old targets, and the current target domain. By pulling visually similar samples from different domains together in the feature space, the model bridges the domain gap.

Overview of the GRCL architecture, illustrating the interaction between the feature bank, momentum updates, and the unified contrastive loss.

Gradient-Based Constraints

GRCL employs two primary constraints during the optimization process to ensure that adaptation to new domains does not compromise existing knowledge:

  1. Source Discriminative Constraint: Ensures that weight updates do not increase the classification loss on the labeled source data, preserving the model's foundational discriminative power.
  2. Target Memorization Constraint: Prevents the update from increasing the loss on previously seen target domains. For these unlabeled domains, the model utilizes high-confidence pseudo-labels generated through clustering.

Optimization via Quadratic Programming

The model seeks an update vector that is as close as possible to the ideal contrastive gradient while remaining within the "safe zones" defined by the source and target constraints. This is formulated as a Quadratic Programming (QP) problem, ensuring that the inner product of the update and the constraint gradients remains non-negative, effectively preventing the model from "backsliding" on old tasks.

Experimental Evaluation

The effectiveness of GRCL was rigorously tested across three major benchmarks representing different types of domain shifts:

  • Digits: A sequence involving five datasets (SynNum → MNIST → MNIST-M → USPS → SVHN).
  • DomainNet: A large-scale dataset featuring five distinct artistic styles (Clipart → Real → Infograph → Sketch → Painting).
  • Office-Caltech: A standard domain adaptation benchmark involving four domains (DSLR, Amazon, WebCam, Caltech).

Key Results and Insights

The experimental results highlight several critical advantages of the GRCL approach:

  • Superior Accuracy: GRCL consistently outperformed state-of-the-art methods, such as CUA, by over 5% in Average Accuracy (ACC) across all benchmarks.
  • Minimal Forgetting: The framework demonstrated remarkable stability. On the Office-Caltech benchmark, GRCL even achieved positive "Backward Transfer" (0.05), suggesting that learning new domains can synergistically enhance performance on earlier ones.
  • The Anchor Effect: A significant qualitative insight is that strictly preserving source features acts as a catalyst for adaptation. By maintaining the discriminative power of the original labeled data, the model provides a stable anchor for the entire feature space as it evolves.
Qualitative visualization of feature alignment and quantitative performance comparison on the Digit benchmark.

Limitations and Future Directions

Despite its strong performance, GRCL has areas for further refinement. The reliance on an episodic memory to store samples from previous domains may be a constraint in extremely memory-limited environments. Additionally, the Target Memorization Constraint depends on the accuracy of pseudo-labels; poor initial adaptation could lead to the reinforcement of incorrect labels. Finally, while the optimization is simplified for efficiency, the calculation of multiple gradient constraints adds computational overhead compared to standard backpropagation.

Future research will explore "data-free" continual domain adaptation to eliminate the need for raw sample storage and investigate more robust pseudo-labeling techniques to handle highly noisy target domains.

Summary updated

BibTeX
@inproceedings{tang2021gradient,
  author = {Shixiang Tang and Peng Su and Dapeng Chen and Wanli Ouyang},
  title = {{Gradient Regularized Contrastive Learning for Continual Domain Adaptation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i3.16370},
}
Figure