Dynamic Domain Adaptation for Efficient Inference

Shuang Li, Jinming Zhang, Wenxuan Ma, Chi Harold Liu, Wei Li

Abstract

Domain adaptation (DA) enables knowledge transfer from a labeled source domain to an unlabeled target domain by reducing the cross-domain distribution discrepancy. Most prior DA approaches leverage complicated and powerful deep neural networks to improve the adaptation capacity and have shown remarkable success. However, they may have a lack of applicability to real-world situations such as real-time interaction, where low target inference latency is an essential requirement under limited computational budget. In this paper, we tackle the problem by proposing a dynamic domain adaptation (DDA) framework, which can simultaneously achieve efficient target inference in low-resource scenarios and inherit the favorable cross-domain generalization brought by DA. In contrast to static models, as a simple yet generic method, DDA can integrate various domain confusion constraints into any typical adaptive network, where multiple intermediate classifiers can be equipped to infer "easier" and "harder" target data dynamically. Moreover, we present two novel strategies to further boost the adaptation performance of multiple prediction exits: 1) a confidence score learning strategy to derive accurate target pseudo labels by fully exploring the prediction consistency of different classifiers; 2) a class-balanced self-training strategy to explicitly adapt multi-stage classifiers from source to target without losing prediction diversity. Extensive experiments on multiple benchmarks are conducted to verify that DDA can consistently improve the adaptation performance and accelerate target inference under domain shift and limited resources scenarios.

Introduction

In deep learning, a persistent tension exists between model accuracy and inference speed. While large-scale neural networks excel at handling "domain shift"—the discrepancy between training (source) and deployment (target) environments—their high computational cost often precludes real-time use on edge devices. Conversely, dynamic networks with early-exit mechanisms offer efficiency but typically falter under domain shift because their shallow layers lack the robustness of deeper features.

To bridge this gap, researchers from the Beijing Institute of Technology and Inceptio Tech introduced Dynamic Domain Adaptation (DDA). This framework enables models to adapt to new environments while dynamically adjusting computational effort based on the difficulty of individual inputs.

The DDA Framework

The DDA framework is designed to be generic, though it was primarily evaluated using the Multi-Scale Dense Network (MSDNet) architecture. It addresses the efficiency-robustness trade-off through three innovative components:

  1. Multi-Exit Domain Confusion: Unlike traditional DA that adapts only the final output, DDA applies domain adversarial losses to every intermediate classifier. This forces the network to learn domain-invariant features at multiple scales, ensuring that even early exits remain reliable under distribution shifts.
  2. Target Confidence Score Learning: To improve self-training, DDA moves beyond simple probability thresholds. It calculates a confidence score based on the prediction consistency (cosine similarity) between all internal classifiers and their average prediction. High consistency indicates a trustworthy sample for pseudo-labeling.
  3. Class-balanced Self-training: To maintain prediction diversity and avoid class imbalance, DDA selects a balanced set of pseudo-labeled samples across categories. These are then used to retrain different exits, preventing the model from collapsing into a state where all classifiers merely mimic one another.
The DDA framework integrates multi-exit classifiers with domain confusion and confidence-based self-training.

Experimental Evaluation

The researchers benchmarked DDA against state-of-the-art static and dynamic models on three major datasets: Office31, VisDA-2017, and DomainNet.

Performance and Efficiency

The results demonstrate that DDA consistently achieves a superior Pareto frontier of accuracy versus computational budget. On the Office31 dataset, DDA achieved a 2.1% accuracy improvement over a ResNet50+DANN baseline while requiring 4x fewer floating-point operations (FLOPs). On the large-scale VisDA-2017 dataset, it outperformed the much heavier ResNet152+CDAN by 4.5% while reducing computational costs by 3.6x.

Accuracy vs. computational budget (MUL-ADD) across various benchmarks and DA methods.

Anytime Prediction

DDA also excels in "anytime prediction" scenarios, where inference might be terminated at any point. Compared to existing methods like REDA, DDA provides smoother and more accurate predictions across all budget levels, proving its robustness in resource-constrained environments.

Discussion and Conclusion

DDA represents a significant step toward deploying robust AI in real-world, low-latency applications. By leveraging the "easy vs. hard" nature of data—where clear images are processed by shallow layers and complex ones by deeper ones—DDA optimizes resource allocation without sacrificing accuracy.

While currently focused on image classification, future work could extend DDA to more complex tasks such as object detection or semantic segmentation. Additionally, exploring the framework's performance on other dynamic architectures remains a promising avenue for research.

Summary updated

BibTeX
@inproceedings{li2021dynamic,
  author = {Shuang Li and Jinming Zhang and Wenxuan Ma and Chi Harold Liu and Wei Li},
  title = {{Dynamic Domain Adaptation for Efficient Inference}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2021},
  url = {https://openreview.net/forum?id=g6U__m8zZWN},
}
Figure