Metric-learning-assisted domain adaptation

Haifeng Hu, Yueming Yin, Zhen Yang, Haifeng Hu 0004, Xiaofu Wu

TL;DR

Standard unsupervised domain adaptation methods align feature distributions between source and target domains, but often leave target samples dangerously close to decision boundaries. Metric-Learning-Assisted Domain Adaptation (MLA-DA) solves this by introducing a novel triplet loss with an adaptive margin based on target prediction uncertainties, successfully pushing target features away from ambiguous boundaries and boosting classification accuracy.

What Problem Does This Paper Address?

Unsupervised Domain Adaptation (UDA) aims to train a model on a labeled source domain and successfully deploy it on an unlabeled target domain. Most existing methods rely heavily on Domain Alignment (DA), which matches the feature distributions of both domains using adversarial training.

However, the authors point out a critical flaw: aligning distributions does not guarantee a low target risk. Because deep neural networks are highly complex and prone to overfitting the source domain, target features often end up clustered right along the decision boundaries or even misaligned on the wrong side.

An illustration of (a) standard domain alignment vs (b) metric-learning-assisted domain alignment (MLA-DA).

As shown above, standard DA can leave target samples ambiguous and prone to misclassification. MLA-DA aims to separate these target features from decision boundaries to improve generalization.

Methods

Since target data lacks labels, the model cannot directly enforce a margin between target classes. Instead, MLA-DA achieves this indirectly by widening the margins between source categories and leveraging the aligned nature of the two domains.

The core innovation is a triplet loss with a dynamic, adaptive margin. To determine how close an unlabeled target sample is to a decision boundary, the authors look at its second largest prediction probability. If a sample is near the boundary, its top two class probabilities will be close (indicating high uncertainty).

Discovery of misclassified samples near the decision boundary and their corresponding prediction probabilities.

MLA-DA dynamically adjusts the triplet loss margin ($\alpha$) in each mini-batch based on these target prediction probabilities. This forces the network to learn more discriminative, well-separated features for the source domain, which naturally pulls the aligned target features away from the decision boundaries. The total loss function combines:

  1. Source classification loss ($L_C$)
  2. Domain alignment loss ($L_D$)
  3. Target entropy minimization ($L_E$)
  4. The proposed dynamic triplet loss ($L_T$)

Datasets

The authors evaluated MLA-DA on four standard UDA benchmarks:

  • Office-31: Contains 4,110 images across 31 classes from three distinct domains: Amazon (A), Webcam (W), and DSLR (D).
  • Office-Home: A more challenging dataset containing 4 domains (Art, Clipart, Product, Real-World) with 65 categories of everyday objects.
  • VisDA2017: A large-scale simulation-to-real dataset containing over 280,000 images across 12 classes, testing the transition from synthetic 3D models to real-world images.
  • ImageCLEF-DA: A benchmark selecting common categories shared across Caltech-256, ImageNet ILSVRC 2012, and Pascal VOC 2012.

Key Insights and Ideas

  • The "Second-Best" Proxy: The second-highest class probability serves as an elegant, unsupervised indicator of a sample's proximity to the decision boundary.
  • Indirect Separation: You don't need target labels to separate target features. By expanding the margin between source classes in an aligned feature space, the target features are forced to separate as well.
  • Alignment Alone is Insufficient: The paper clearly demonstrates that low source error plus perfect distribution alignment can still fail if the target features lack discriminative structure near boundaries, especially when the source dataset is small.

Key Results

MLA-DA consistently outperformed state-of-the-art methods (such as CDAN, MCD, and DANN) across all four benchmarks:

  • Office-31: MLA-DA achieved an average accuracy of 88.1%, outperforming the strong CDAN baseline (86.6%). It showed massive improvements on small-to-large transfer tasks like D→A (74.7% vs CDAN's 70.1%).
  • Office-Home: Reached an average accuracy of 66.8% compared to CDAN's 63.8%.
  • VisDA2017: Achieved a top score of 75.5% accuracy on the Synthetic→Real challenge.
  • Robustness to Noise & Data Scarcity: When the source domain size was heavily downsampled, standard DA performance degraded rapidly, whereas MLA-DA maintained stable performance. It also demonstrated superior anti-noise capabilities when tested against virtual adversarial training (VAT) noise.

Limitations and Future Work

The authors do not explicitly detail limitations, but the method inherently relies on the initial quality of the model's prediction probabilities. If the initial domain shift is so severe that the pseudo-labels and secondary probabilities are completely inaccurate, the dynamic margin calculation could introduce misleading training signals. Future work could explore self-correcting mechanisms for these probabilities early in the training phase.

Summary updated

BibTeX
@article{hu2021metric,
  author = {Haifeng Hu and Yueming Yin and Zhen Yang and Haifeng Hu and Xiaofu Wu},
  title = {{Metric-learning-assisted domain adaptation}},
  journal = {Neurocomputing},
  year = {2021},
  doi = {10.1016/j.neucom.2021.05.023},
}
Figure