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:
- Task: Defines the data, specifying which domains are used for training, validation, and testing.
- Model: Defines the architecture and "instance-wise" regularization losses (e.g., DANN or DIVA), which typically require auxiliary neural networks.
- 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.
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