Uncertainty Modeling in Graph Neural Networks via Stochastic Differential Equations

Richard Bergna, Sergio Calvo-Ordoñez, Felix L. Opolka, Pietro Liò, Jose Miguel Hernandez-Lobato

Graph Neural Networks (GNNs) have become the workhorse for everything from social network analysis to drug discovery. However, they share a common flaw with many deep learning models: they are often overconfident. In high-stakes fields like medicine or finance, a model that doesn't know when it's guessing is a liability.

A new paper accepted at ICLR 2025, "Uncertainty Modeling in Graph Neural Networks via Stochastic Differential Equations," introduces a framework called Latent Graph Neural Stochastic Differential Equations (LGNSDE) to fix this. By moving from deterministic paths to stochastic ones, the authors provide a way for GNNs to "know what they don't know."

TL;DR

LGNSDE is a novel framework that uses Stochastic Differential Equations (SDEs) to model both aleatoric (data noise) and epistemic (model knowledge) uncertainty in graph data. It provides rare theoretical guarantees that its uncertainty estimates are mathematically bounded and robust, outperforming traditional Bayesian GNNs and ensembles in detecting out-of-distribution data.

What Problem Does This Paper Address?

Traditional GNNs are deterministic; given an input graph, they produce a single fixed representation for each node. Even "continuous" versions like Graph Neural Ordinary Differential Equations (GNODEs) follow a fixed trajectory through latent space.

The problem is that real-world data is messy. There is aleatoric uncertainty (inherent noise in the data, like a blurry image or a missing link) and epistemic uncertainty (uncertainty due to a lack of training data in a specific region). Standard GNNs collapse all this complexity into a single point, leading to overconfident predictions on "out-of-distribution" (OOD) data—samples the model has never seen before.

Methods

The authors propose treating the evolution of node features as a stochastic process rather than a fixed path.

  1. Latent SDEs: Instead of a standard neural layer, the model defines the change in node features $H(t)$ using an SDE: $$dH(t) = f(H(t), t)dt + g(H(t), t)dW(t)$$ Here, $f$ is the "drift" (the direction the features want to move, learned by a GCN), and $g$ is the "diffusion" (the randomness, driven by Brownian motion $dW(t)$).

  2. Dual Uncertainty Modeling:

    • Aleatoric: Captured by the Brownian motion noise injected during the forward pass.
  3. Epistemic: Captured via a Bayesian prior-posterior mechanism. The model assumes a simple prior SDE (like an Ornstein-Uhlenbeck process) and learns a posterior SDE that best fits the data.
  4. Theoretical Guarantees: Unlike many heuristic approaches, the authors prove that the variance of the model's output is mathematically bounded by the variance of the latent space. They also prove the model is stable, meaning small perturbations in the input graph won't cause the latent trajectories to explode.
Figure 1: The diagram shows the evolution of one of the nodes of the input graph in latent space, H(t), through an SDE, with sample paths (purple) and confidence bands representing variance. At three timesteps, we visualize graph embeddings, where nodes (white and orange) become more separable over time due to the influence of the vector field. The inset axes represent latent dimensions, while the purple and yellow background highlights the magnitude and direction of the vector field guiding the latent dynamics.

Datasets

The framework was evaluated on five standard graph benchmarks:

  • Citation Networks: Cora, CiteSeer, and PubMed.
  • Amazon Co-purchasing Graphs: Computers and Photo.

These were used to test standard node classification, OOD detection (by leaving out one class during training), and robustness to Gaussian noise added to input features.

Key Insights and Ideas

  • Continuous Depth as Complexity Control: In LGNSDE, the "depth" of the model is tied to the integration time of the SDE. The SDE solver can dynamically adjust the number of steps based on the difficulty of the task—simpler graphs require fewer "layers," while complex ones get more.
  • Meaningful Variance: The "aha moment" here is the proof that latent variance bounds output variance. This ensures that when the model shows high variance (uncertainty) in its latent space, it translates to a truly cautious prediction at the output.
  • Superior OOD Separation: Most models struggle to distinguish between "I'm sure this is Class A" and "I've never seen anything like this." LGNSDE shows a much clearer separation in entropy between in-distribution and OOD samples.

Key Results

  • Out-of-Distribution Detection: LGNSDE achieved a 50% higher mean entropy for OOD data compared to in-distribution data. Competing models like Bayesian GCNs or Ensembles typically showed less than a 10% difference.
  • Robustness: In noise perturbation tests, LGNSDE consistently ranked in the top two across all datasets for AUROC and Accuracy, validating the theoretical claim that the SDE framework handles input noise gracefully.
  • Active Learning: When used to select which nodes to label next (active learning), LGNSDE's entropy-based selection led to faster accuracy improvements than random selection or other uncertainty-aware models.
Figure 2: Entropy distributions. The top row shows that LGNSDE has a wider gap in entropy between correct and incorrect predictions. The bottom row shows the superior separation between In-Distribution (blue) and OOD (red) samples compared to other methods.

Limitations and Future Work

  • Computational Overhead: The primary trade-off is speed. As shown in Table 12, LGNSDE takes about 1.23 seconds per epoch on Cora, compared to just 0.19 seconds for a standard GCN. This is the "tax" paid for numerical SDE integration.
  • Solver Optimization: The authors note that exploring more efficient, adaptive SDE solvers is a key next step to make this viable for massive, real-time graphs.
  • Scaling to Dynamic Graphs: While the model uses "time" as a latent depth, applying it to graphs that actually change over physical time (like traffic or social feeds) remains an open research direction.

Summary updated

Abstract

We propose a novel Stochastic Differential Equation (SDE) framework to address the problem of learning uncertainty-aware representations for graph-structured data. While Graph Neural Ordinary Differential Equations (GNODEs) have shown promise in learning node representations, they lack the ability to quantify uncertainty. To address this, we introduce Latent Graph Neural Stochastic Differential Equations (LGNSDE), which enhance GNODE by embedding randomness through a Bayesian prior-posterior mechanism for epistemic uncertainty and Brownian motion for aleatoric uncertainty. By leveraging the existence and uniqueness of solutions to graph-based SDEs, we prove that the variance of the latent space bounds the variance of model outputs, thereby providing theoretically sensible guarantees for the uncertainty estimates. Furthermore, we show mathematically that LGNSDEs are robust to small perturbations in the input, maintaining stability over time. Empirical results across several benchmarks demonstrate that our framework is competitive in out-of-distribution detection, robustness to noise, and active learning, underscoring the ability of LGNSDEs to quantify uncertainty reliably. Code is available at \href{https://github.com/Richard-Bergna/GraphNeuralSDE}{\texttt{github.com/Richard-Bergna/GraphNeuralSDE}}.
BibTeX
@inproceedings{bergna2025uncertainty,
  author = {Richard Bergna and Sergio Calvo-Ordoñez and Felix L. Opolka and Pietro Liò and Jose Miguel Hernandez-Lobato},
  title = {{Uncertainty Modeling in Graph Neural Networks via Stochastic Differential Equations}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=TYSQYx9vwd},
}
Figure