Batch Normalization Embeddings for Deep Domain Generalization

Mattia Segù, Alessio Tonioni, Federico Tombari

TL;DR

This paper introduces Batch Normalization Embeddings (BNE), a novel approach to domain generalization that leverages the statistics learned by batch normalization layers to create a latent "domain space." By mapping both known and unknown domains into this space, BNE can effectively infer domain properties and improve classification accuracy on unseen domains, outperforming existing state-of-the-art methods.

What Problem Does This Paper Address?

Machine learning models often struggle to generalize to new datasets or environments that differ from their training data, a phenomenon known as "domain shift." This is a significant hurdle for deploying AI in real-world scenarios where data distributions can vary widely. While domain adaptation techniques can help by using a small amount of labeled target data, domain generalization aims to achieve robustness without any target data at all. Existing domain generalization methods often try to learn domain-invariant features, effectively discarding domain-specific information. This paper argues that this might be detrimental and proposes a method that explicitly leverages domain-specific representations to build a more robust model.

Methods

The core innovation of this paper is the use of Batch Normalization Embeddings (BNE). Here's how it works:

  • Domain-Specific Batch Normalization Statistics: Instead of using a single batch normalization layer for all domains, BNE maintains separate statistics (mean and variance) for each training domain. This allows the network to learn distinct representations for each domain.
  • Batch Normalization Embedding (BNE) Space: The collected population statistics from the batch normalization layers across different layers of the network are used to define a "domain space." Each training domain is mapped to a point (embedding) in this space.
  • Domain Localization: At test time, for an unseen sample, its instance normalization statistics (effectively batch normalization with a batch size of 1) are computed. These statistics are then used to project the sample into the same BNE space.
  • Distance-Based Weighting: The distance between the test sample's embedding and the known domain embeddings in the BNE space is calculated. This distance is then used to infer the similarity of the test sample to each training domain.
  • Lightweight Ensemble: The final prediction for a test sample is a weighted combination of predictions from domain-specific models. The weights are derived from the calculated domain similarities, effectively interpolating between known domain models based on the test sample's inferred domain. This ensemble shares most parameters, making it lightweight.
  • Training Policy: The training process incorporates the distance weighting strategy to encourage the BNE space to be well-defined and to learn stable population statistics before distance training begins.

Datasets

The proposed method was evaluated on three standard domain generalization benchmarks:

  • PACS: Features 4 domains (Art Painting, Cartoon, Photo, Sketch) with significant domain shifts.
  • Office-31: A dataset commonly used for domain adaptation, adapted for domain generalization, comprising images from a webcam, a DSLR camera, and the Amazon website.
  • Office-Caltech: A combination of Office-31 and the Caltech-256 dataset, sharing 10 categories.

Key Insights and Ideas

  • Leveraging Domain-Specific Information is Key: The paper challenges the common practice of forcing domain invariance. It argues that explicitly learning and utilizing domain-specific representations, rather than discarding them, leads to better generalization.
  • Batch Normalization as a Domain Encoder: BNE reveals that batch normalization layers, often treated as a normalization tool, can implicitly encode rich domain-specific information. Their statistics can be used to create meaningful embeddings of domains.
  • A Unified Latent Space for Domains: The BNE space provides a principled way to represent and compare domains. This allows for a more nuanced understanding of domain relationships and sample-wise domain attribution.
  • Lightweight and Flexible: The method relies on a lightweight ensemble and can be applied to any CNN architecture that uses batch normalization layers, making it broadly applicable.

Key Results

The BNE method demonstrated strong performance across the evaluated benchmarks:

  • PACS: Achieved an average accuracy of 83.1% with a relative gain of +5.86% over the baseline, making it the second most effective algorithm on this dataset. It showed a particularly significant gain (+9.6% absolute) on the challenging "Sketch" domain.
  • Office-31: Outperformed baselines and competitors, achieving the best absolute accuracy in two out of three test scenarios and a significant boost of +11.2% on the challenging Amazon target domain.
  • Office-Caltech: Showed the best average accuracy and gain with respect to the baseline.
  • Ablation Studies: Demonstrated that each component of BNE (domain-specific statistics, distance weighting, and warm-up phase) contributes to improved performance.

Limitations and Future Work

  • Batch Size Impact: The paper notes that larger batch sizes generally lead to better generalization, suggesting that the approximation of true population statistics is crucial.
  • Distance Metric Choice: While Wasserstein distance was found to be a principled choice, the paper acknowledges that other distances could be explored.
  • Future Directions: The authors suggest extending the method to domain adaptation by incorporating unlabeled target samples during training. They also propose exploring the use of few labeled target samples to retrieve a less biased estimate of unseen domain statistics. Furthermore, they plan to investigate combining BNE with other normalization methods and exploring its application to different tasks.

Summary updated

BibTeX
@article{segu2020batch,
  author = {Mattia Segù and Alessio Tonioni and Federico Tombari},
  title = {{Batch Normalization Embeddings for Deep Domain Generalization}},
  journal = {Pattern Recognition},
  year = {2020},
  doi = {10.1016/j.patcog.2022.109115},
}
Figure