Random-Effects Centroids for Domain Generalization
Abstract
Domain generalization (DG) aims to learn from multiple source environments and perform well on unseen target environments. A common practice is to pool the source data and deploy a single predictor, which implicitly weights each environment by its sample size. We study a different deployment object, in which each source environment has its own expert head on a shared representation. The experts are combined with fixed simplex weights that require no environment label at test time. We show that under a same-meta random-effects model, where the environment-specific optimal heads scatter iid around a shared meta-mean, the optimal fixed weights are uniform. With a common feature second moment, the uniform average of the optimal heads, the uniform centroid, reduces excess risk relative to pooling by an amount that grows with the imbalance in sample sizes. Meanwhile, uniform weights alone do not make the trained average accurate, since its accuracy depends on how the experts and the shared representation are learned. We introduce REC (Random-Effects Centroid), a training objective that fits the experts and directly trains their uniform average on every source environment. In the same setting, its centroid term controls both the distance of the trained average from the uniform centroid and the dispersion of the optimal heads. Synthetic experiments isolate the population-level effect of the weighting and probe learned-representation behavior. WILDS experiments show that REC is competitive with established DG baselines and that the centroid term is necessary for a useful averaged predictor.