Abstract
Out-of-distribution (O.O.D.) generalization remains to be a key challenge for real-world machine learning systems. We describe a method for O.O.D. generalization that, through training, encourages models to only preserve features in the network that are well reused across multiple training domains. Our method combines two complementary neuron-level regularizers with a probabilistic differentiable binary mask over the network, to extract a modular sub-network that achieves better O.O.D. performance than the original network. Preliminary evaluation on two benchmark datasets corroborates the promise of our method.
Introduction
Deep neural networks often struggle with out-of-distribution (OOD) generalization because they tend to exploit spurious correlations—shortcuts in training data that do not hold in the real world. For instance, a model might identify a digit based on its color rather than its shape if color is correlated with the label in the training set. To address this, we propose that modularity—organizing networks into specialized, reusable components—is essential for learning robust representations that generalize beyond training domains.
Methodology: Enforcing Modularity
Our approach utilizes differentiable probabilistic binary masks ($\pi$) over network weights to learn an optimal sub-structure during training. We introduce two novel regularization terms to enforce modularity:
- Specialization ($S_1$): This term encourages "sparse fitting" by ensuring each feature is a unique composition of minimal sub-features. It minimizes redundancy by penalizing overlapping feature usage.
- Reuse ($S_2$): Inspired by group lasso regularization, this term preserves features that are consistently reused across different domains. It helps the network distinguish between generalizable knowledge and domain-specific noise.
By integrating these regularizers with a Gumbel-Sigmoid estimator, the network co-evolves its weights and its modular structure, effectively pruning non-essential components that might otherwise capture spurious signals.
Experimental Evaluation
We evaluated our method on two standard OOD benchmarks:
- Colored MNIST (C-MNIST): A dataset where color-label correlations are reversed between training and testing, creating a significant "trap" for standard models.
- Rotated MNIST (R-MNIST): A dataset where digits are rotated at various angles, requiring the model to learn rotation-invariant features.
Results
The proposed modular regularization (modReg) was tested as an add-on to Empirical Risk Minimization (ERM) and Invariant Risk Minimization (IRM).
As shown in the table above, modReg consistently improves performance across different architectures and datasets:
- C-MNIST Improvements: On the highly biased C-MNIST dataset, adding
modRegto IRM increased accuracy from 67.69% to 71.88% for CNNs, and from 72.58% to 75.59% for MLPs. - Robustness Across Architectures: The gains are not limited to a specific model type, demonstrating the general applicability of the modular inductive bias.
- Performance in Stable Domains: Even in R-MNIST, where baseline performance is already high,
modRegprovided incremental gains, such as reaching 98.1% accuracy with IRM + modReg on a CNN.
Conclusion and Future Work
This work demonstrates that structurally enforcing modularity through specialization and reuse regularizers can significantly enhance OOD generalization. While preliminary results on MNIST-scale datasets are promising, future research will focus on scaling this approach to larger datasets like ImageNet and more complex architectures like Transformers, as well as investigating the sensitivity of the model to its hyperparameters.
Summary updated