NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

DomainLab: A modular Python package for domain generalization in deep learning

Xudong Sun, Carla Feistner, Alexej Gossmann, George Schwarz, Rao Muhammad Umer, Lisa Beer, Patrick Rockenschaub, Rahul Babu Shrestha, Armin Gruber, Nutan Chen, Sayedali Shetab Boushehri, Florian Buettner, Carsten MarrarXiv 2024 · DOI

Abstract

DomainLab is a modular Python library designed to streamline research in domain generalization (DG). By decoupling neural network architectures from regularization strategies and training logic, it allows researchers to mix, match, and benchmark complex DG methods through simple configuration files rather than extensive code rewrites. This framework addresses the "reproducibility crisis" in DG by providing a software architecture that is closed to core modification but open to extension.

Introduction

Deep neural networks are notoriously brittle when faced with distribution shifts, where real-world data (the "unseen domain") differs from training data. Domain Generalization (DG) aims to solve this by learning features that remain invariant across different environments. However, the field suffers from a reproducibility crisis; most DG implementations are proof-of-concept scripts where data loading, model architecture, and loss functions are tightly coupled. DomainLab addresses this by providing a software framework that adheres to the "open-closed principle," making it easy to extend with new methods without modifying the core codebase.

Methodology

The core innovation of DomainLab is its decoupled design, which separates the DG problem into three distinct modules:

  1. Task: Defines the data, specifying which domains are used for training, validation, and testing.
  2. Model: Defines the architecture and "instance-wise" regularization losses (e.g., DANN or DIVA), which typically require auxiliary neural networks.
  3. Trainer: Defines the optimization logic and "flow-based" regularization (e.g., MLDG or FishR), managing specific data-handling strategies like meta-learning splits.

This separation allows for hierarchical combinations via software design patterns. Users can "decorate" a trainer with another trainer's logic and apply it to a hybrid model, managing this complexity through a single YAML configuration file.

Datasets and Interfaces

DomainLab includes built-in support for standard DG benchmarks and provides flexible interfaces for custom data:

  • Built-in: Color-MNIST, PACS (Photos, Art, Cartoons, Sketches), and VLCS.
  • Custom Data Interfaces:
  • TaskDset: Direct use of PyTorch Datasets.
  • TaskFolder: For data organized in nested domain/class directories.
  • TaskPathFile: For specifying data via text files containing paths and labels.

Experimental Results

The authors demonstrate the library's utility by benchmarking several popular DG methods on the PACS dataset using a ResNet50 backbone. The package integrates with Snakemake to automate large-scale experiments, handling random seed sampling and hyperparameter grids automatically.

Out-of-domain accuracy distributions for various DG methods on the PACS dataset. The box plots reveal the performance variance across hyperparameter combinations and random seeds.

As shown in the figure above, the benchmarking tool reveals critical nuances often hidden in standard reports:

  • Baseline Strength: Empirical Risk Minimization (ERM) remains a surprisingly competitive baseline, often matching or exceeding more complex DG methods.
  • Hyperparameter Sensitivity: Many methods, such as DANN or DIAL, show high variance in performance depending on hyperparameter choices. In some cases, poor configurations lead to "failed training," where accuracy drops to near-zero.

Conclusion

DomainLab provides a robust framework for implementing and testing DG methods by formalizing the difference between model-based and trainer-based regularization. While the package is designed to be "closed to modification" of its core logic, it significantly lowers the barrier for researchers to compose and benchmark new algorithms. Future work involves expanding the library of built-in methods and further optimizing the benchmarking pipeline for larger-scale foundation models.

Summary updated

BibTeX
@misc{sun2024domainlab,
  author = {Xudong Sun and Carla Feistner and Alexej Gossmann and George Schwarz and Rao Muhammad Umer and Lisa Beer and Patrick Rockenschaub and Rahul Babu Shrestha and Armin Gruber and Nutan Chen and Sayedali Shetab Boushehri and Florian Buettner and Carsten Marr},
  title = {{DomainLab: A modular Python package for domain generalization in deep learning}},
  year = {2024},
  eprint = {2403.14356},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.14356},
}
Figure