Bilevel optimization for learning hyperparameters: Application to solving PDEs and inverse problems with Gaussian processes

Nicholas H. Nelsen, Houman Owhadi, Andrew M. Stuart, Xianjin Yang, Zongren ZouarXiv 2025 · DOI

Abstract

Solving partial differential equations (PDEs) using Gaussian processes (GPs) offers a mesh-free approach with inherent uncertainty quantification. However, the performance of these methods is highly sensitive to hyperparameter selection, such as kernel lengthscales. Traditional bilevel optimization for hyperparameter tuning is computationally expensive, especially for nonlinear PDEs. This paper introduces a novel bilevel optimization strategy that employs a single Gauss-Newton (GN) linearization step to bypass full inner-loop PDE solves. This method facilitates fast, scalable hyperparameter learning, even for high-dimensional parameter spaces defined by neural networks, resulting in significant accuracy improvements for both forward and inverse problems.

Introduction

Machine learning and kernel-based methods are increasingly utilized for solving PDEs and inverse problems. While these methods provide flexibility, their success depends on carefully tuned hyperparameters. A poor choice of lengthscale, for instance, can lead to over-smoothing or numerical instability. The standard approach—bilevel optimization—requires solving the PDE (the inner problem) for every update of the hyperparameters (the outer problem). For nonlinear PDEs, this inner loop is a costly optimization task, making the overall process computationally prohibitive.

Methodology

The proposed method avoids the computational burden of fully solving the inner PDE problem at each iteration. Instead, the authors replace the inner problem with a single Gauss-Newton linearization around the current state.

Gauss-Newton Linearization

By linearizing the PDE constraints, the inner problem is transformed into a linearly constrained quadratic program. According to the representer theorem, this transformed problem has a closed-form solution. This explicit formula allows the outer loop to compute gradients (hypergradients) with respect to the hyperparameters using standard automatic differentiation, avoiding memory-intensive unrolling or high-accuracy implicit differentiation.

The authors describe two implementations:

  1. Optimize-Then-Discretize (OTD): The PDE is linearized in continuous function space before discretizing the outer loss using validation points.
  2. Discretize-Then-Optimize (DTO): A discrete set of validation points is fixed upfront, and residuals are linearized at those specific points for optimization.

Experimental Evaluation

The method was evaluated on several canonical PDEs to demonstrate its versatility:

  • 1D and 2D nonlinear elliptic equations.
  • The complex-valued nonlinear Schrödinger equation.
  • The Gray-Scott reaction-diffusion system.
  • Eikonal and Burgers' equations.
  • Inverse problems, such as Darcy flow, where the goal is to reconstruct a hidden permeability field from noisy pressure observations.

Key Results

The bilevel optimization approach demonstrates significant improvements in accuracy and robustness across all tested scenarios:

  • Accuracy Gains: In solving the Burgers' equation, the learned kernel reduced the $L^2$ error from $1.5 \times 10^{-1}$ (unlearned) to $9.5 \times 10^{-6}$.
  • Robustness to Initialization: The optimization reliably converges to optimal hyperparameter values regardless of where they are initialized. In elliptic equation tests, initial lengthscales ranging from 0.05 to 3.0 converged to the same optimal value (~0.2).
  • Scalability: The framework successfully optimized over 2,800 hyperparameters for a neural network-parameterized kernel, effectively capturing sharp features in the Eikonal and Burgers' equations.
L2 error as a function of lengthscale $\theta$ for varying numbers of collocation points $M$. The plots show a clear global minimum, indicating the optimal hyperparameter value that the bilevel optimization targets.

Discussion and Future Work

A key insight of this work is that a perfectly converged inner solve is unnecessary for obtaining useful gradients for hyperparameter updates; a single GN step serves as an effective surrogate. Furthermore, hyperparameters learned on specific initial conditions generalize well to different setups, suggesting the model learns the underlying physics and regularity of the PDE rather than just overfitting a single instance.

Despite its success, the method's reliance on dense Gram matrices poses a scalability challenge for extremely large-scale or high-dimensional problems. Future research will explore accelerating linear solves via randomized sketching or sparse Cholesky factorizations and extending the framework to operator learning architectures like DeepONets and Fourier Neural Operators.

Summary updated

Abstract

Methods for solving scientific computing and inference problems, such as kernel- and neural network-based approaches for partial differential equations (PDEs), inverse problems, and supervised learning tasks, depend crucially on the choice of hyperparameters. Specifically, the efficacy of such methods, and in particular their accuracy, stability, and generalization properties, strongly depends on the choice of hyperparameters. While bilevel optimization offers a principled framework for hyperparameter tuning, its nested optimization structure can be computationally demanding, especially in PDE-constrained contexts. In this paper, we propose an efficient strategy for hyperparameter optimization within the bilevel framework by employing a Gauss-Newton linearization of the inner optimization step. Our approach provides closed-form updates, eliminating the need for repeated costly PDE solves. As a result, each iteration of the outer loop reduces to a single linearized PDE solve, followed by explicit gradient-based hyperparameter updates. We demonstrate the effectiveness of the proposed method through Gaussian process models applied to nonlinear PDEs and to PDE inverse problems. Extensive numerical experiments highlight substantial improvements in accuracy and robustness compared to conventional random hyperparameter initialization. In particular, experiments with additive kernels and neural network-parameterized deep kernels demonstrate the method's scalability and effectiveness for high-dimensional hyperparameter optimization.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
Complex-valued nonlinear Schrödinger equationGP-PDE with learned hyperparametersL^2 error0.0027Learned lengthscales l_t^u=0.2461, l_x^u=0.1455, l_t^v=0.2476, l_x^v=0.1340; evaluated …
Source quote
L1047: L^2 error │ 0.0027 │ 0.2531 │ 0.1301 │ 0.0297
Complex-valued nonlinear Schrödinger equationGP-PDE with fixed initial hyperparameters (all four lengthscales = 1.0)L^2 error0.2531Fixed lengthscales l_t^u=l_x^u=l_t^v=l_x^v=1.0; evaluated with a new random set of 1,50…
Source quote
L1047: L^2 error │ 0.0027 │ 0.2531 │ 0.1301 │ 0.0297
BibTeX
@misc{nelsen2025bilevel,
  author = {Nicholas H. Nelsen and Houman Owhadi and Andrew M. Stuart and Xianjin Yang and Zongren Zou},
  title = {{Bilevel optimization for learning hyperparameters: Application to solving PDEs and inverse problems with Gaussian processes}},
  year = {2025},
  eprint = {2510.05568},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.05568},
}
Figure