Learning where to learn: Training data distribution optimization for scientific machine learning

Nicolas Guerra, Nicholas H. Nelsen, Yunan Yang

TL;DR

Scientific machine learning models often fail when deployed in physical regimes different from their training data. This paper introduces a principled framework to optimize the training data distribution itself to minimize out-of-distribution error across a family of target deployment scenarios. By framing data acquisition as a bilevel or alternating optimization problem, the authors significantly improve model robustness and sample complexity for complex partial differential equation (PDE) tasks.

What Problem Does This Paper Address?

In scientific machine learning (SciML)—such as learning solution operators for PDEs—models are frequently deployed in environments with boundary conditions or parameter regimes far from those seen during training. Standard Empirical Risk Minimization (ERM) assumes training and test data come from the same distribution, leading to severe performance degradation under out-of-distribution (OOD) shifts.

The authors address the "learning-where-to-learn" problem: how can we proactively design an optimal training data distribution given a known or expected family of deployment regimes? Instead of training on whatever data is easiest to collect or blindly matching a single test distribution, this framework mathematically designs the training data to ensure the model generalizes robustly.

Methods

The authors develop a theoretical foundation using Lipschitz continuity and Wasserstein distances to bound OOD error. Based on this theory, they propose two core optimization algorithms operating directly on the space of probability measures:

  1. Exact Bilevel Formulation (Algorithm 1/3): This directly minimizes average OOD error. The inner loop trains the machine learning model, and the outer loop optimizes the training distribution parameters using an adjoint state method. While mathematically exact, it is currently restricted to linear hypothesis classes like Reproducing Kernel Hilbert Spaces (RKHS).
  2. Upper-Bound Minimization / Alternating Minimization Algorithm (AMA, Algorithm 2): A computationally efficient relaxation that minimizes a theoretical upper bound on the OOD error. It alternates between standard model training and updating the training distribution. Crucially, AMA works with non-linear models like deep neural networks and neural operators (e.g., DeepONet).

These distributions are implemented either parametrically (e.g., optimizing the mean and covariance of a Gaussian process) or nonparametrically (using particle-based representations updated via Wasserstein gradient flows).

Datasets

The methods are evaluated across several synthetic benchmarks and partial differential equation (PDE) problems:

  • Function Approximation Benchmarks: Sobol G ($g_1$) and Friedmann functions ($g_2, g_3$), plus a custom kernel expansion ($g_4$).
  • Neumann-to-Dirichlet (NtD) Map: Linear operator learning related to Electrical Impedance Tomography (EIT).
  • Darcy Flow: Parameter-to-solution operator learning for an elliptic PDE.
  • Radiative Transport Equation: A hyperbolic PDE where the Knudsen number is varied to test different physical regimes.
  • Viscous Burgers' Equation: A non-linear PDE modeling steep shock-like phenomena in fluids.

Key Insights and Ideas

  • Training on the test distribution is suboptimal: Counterintuitively, simply training on samples from the target deployment distribution is rarely the best strategy for regression and operator learning. Proactively shifting or broadening the training distribution yields better generalization.
  • Physics-informed data selection: The optimized training distributions automatically adapt to the mathematical structure of the underlying physical system. For instance, if a PDE solution is highly sensitive (quadratic) to a specific coordinate or parameter, the optimization algorithm automatically places higher weight and variance on that region.
  • Bypassing pool constraints: Unlike standard active learning, which is typically "pool-based" (selecting from a fixed, pre-existing set of unlabeled points), this approach optimizes the generative distribution itself, allowing researchers to sample an arbitrary number of high-quality training points.

Key Results

  • Function Approximation: The proposed bilevel optimization method ("Ours") consistently outperformed standard baselines (Normal, Uniform, Wasserstein Barycenter) and active learning coresets, often reducing relative OOD error by orders of magnitude.
Table 1: Function approximation with bilevel Alg. 1. Reported values are mean Err for kernel regressors trained with 1024 labeled data samples from the optimized νϑ (ours) from Alg. 1 with 1000 iterations vs. other adaptive (aCoreSet) and nonadaptive (Normal, Barycenter, Mixture, Uniform, nCoreSet) sampling distributions. Two standard deviations from the mean Err over 10 independent runs is also reported. Also see Fig. 10.
  • Operator Learning: For the radiative transport equation, particle-based AMA reduced the average relative OOD error by up to 88% compared to the initial model.
  • Robustness to Distribution Shift: In the viscous Burgers' equation task, the AMA-trained DeepONet matched or exceeded pool-based active learning methods, particularly in intermediate sample-size regimes, while offering the added benefit of generating unlimited training samples.
EIT conductivity predictions across different boundary condition distributions

Limitations and Future Work

  • Expressivity of Distribution Families: The parametric approach is limited by the choice of the distribution family (e.g., assuming a Gaussian distribution).
  • Scalability of Exact Bilevel Optimization: The exact bilevel gradient computation is currently limited to linear vector spaces (RKHS) and does not easily scale to deep neural networks without using the upper-bound relaxation (AMA).
  • Optimization Challenges: The optimization landscape contains many local minima, requiring global optimization techniques (like differential evolution) which can be computationally expensive.
  • Future Directions: The authors suggest incorporating transport maps, importance reweighting techniques, and exploring the explicit cost-versus-accuracy trade-offs of sample allocation.

Summary updated

BibTeX
@misc{guerra2025learning,
  author = {Nicolas Guerra and Nicholas H. Nelsen and Yunan Yang},
  title = {{Learning where to learn: Training data distribution optimization for scientific machine learning}},
  year = {2025},
  eprint = {2505.21626},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.21626},
}
Figure