Accurate and Scalable Estimation of Epistemic Uncertainty for Graph Neural Networks

Puja Trivedi, Mark Heimann, Rushil Anirudh, Danai Koutra, Jayaraman J. Thiagarajan

TL;DR

Graph Neural Networks (GNNs) often struggle to provide reliable uncertainty estimates when faced with real-world distribution shifts. This paper introduces G-$\Delta$UQ, a scalable framework that adapts stochastic data centering (anchoring) to graph data to boost a model's intrinsic uncertainty awareness. By supporting partial stochasticity, it can even be applied as a lightweight, plug-and-play addition to frozen, pretrained GNNs.

What Problem Does This Paper Address?

When deep learning models encounter distribution shifts at test time—such as changes in graph size, node features, or graph structure—they tend to become overconfident in their incorrect predictions. Knowing when a model is uncertain is critical for safety-sensitive applications like healthcare or financial fraud detection.

Traditional post-hoc calibration methods fix this issue for data that looks like the training set, but they quickly fail under distribution shifts. While Deep Ensembles offer a robust solution for capturing this "epistemic" uncertainty, training and storing multiple independent models is computationally expensive. A recent single-model alternative in computer vision, $\Delta$-UQ, uses "anchored training" to simulate an ensemble efficiently. However, extending this to graphs is highly non-trivial because graph data is discrete, variable-sized, and non-IID due to node connectivity.

Methods

The authors propose G-$\Delta$UQ, introducing three distinct graph-specific anchoring strategies that trade off the level of network stochasticity against semantic expressivity:

  1. Node Feature Anchoring (NFA): Fits a continuous Gaussian distribution over the training node features. This allows the model to sample unique anchors for variable-sized graphs, creating a fully stochastic GNN.
  2. Hidden Layer Anchoring: Shuffles intermediate node representations across a batch to act as anchors. This creates a partially stochastic GNN where early layers remain deterministic.
  3. Readout Anchoring: Applies anchoring only at the final graph-level representation (after the readout layer) right before the classifier head.

During inference, the model samples $K$ random anchors, passes the query through the anchored layers, and aggregates the predictions. The variance across these anchors serves as a reliable measure of epistemic uncertainty.

Datasets

The framework was evaluated across a diverse suite of benchmarks capturing different distribution shifts:

  • Node Classification Shifts: WebKB, Cora, and CBAS datasets (evaluating covariate and concept shifts).
  • Graph Classification Shifts: GOODCMNIST, GOODMotif-basis, and GOODSST2 from the Graph Out-Of-Distribution (GOOD) benchmark.
  • Graph Size Shifts: NCI1, NCI109, and PROTEINS datasets.
  • Controlled Structural Distortion: A superpixel graph version of Rotated MNIST (RotMNIST).

Key Insights and Ideas

  • Full Stochasticity is Overrated for Graphs: In computer vision, input-space anchoring is standard. However, the authors discover that GNNs benefit significantly from partial stochasticity. Anchoring deeper in the network (like Readout anchoring) preserves structural expressivity while providing excellent functional diversity.
Figure 3: Effect of Anchoring Layer. Anchoring at different layers (L1, L2, L3) induces different hy- potheses spaces. Variations of stochastic anchoring outperform models without it, and the lightweight READOUT anchoring in particular generally performs well across datasets and architectures.
  • Plug-and-Play for Pretrained Models: Because Readout anchoring only modifies the final classification head, it can be applied directly to massive, pretrained GNN backbones. You freeze the GNN backbone and only train the small anchored classifier head, dramatically cutting down computational overhead.
  • Expressivity $\neq$ Calibration: More advanced architectures like Graph Transformers (GPS) are not inherently better calibrated under severe distribution shifts than simpler Message Passing Neural Networks (MPNNs), highlighting the need for explicit uncertainty frameworks like G-$\Delta$UQ.

Key Results

  • Superior Out-of-the-Box Calibration: G-$\Delta$UQ consistently reduces the Expected Calibration Error (ECE) across various distribution shifts without hurting classification accuracy. On the GOOD benchmark, it improved out-of-the-box calibration on 5 out of 6 datasets.
  • Enhanced Safety Metrics: The framework directly improves performance on downstream safety tasks. For Out-of-Distribution (OOD) detection, G-$\Delta$UQ variants outperformed vanilla models on 6 out of 8 datasets in AUROC. It also achieved state-of-the-art performance in Generalization Error Prediction (GEP).
  • Massive Efficiency Gains: Pretrained G-$\Delta$UQ cuts training time significantly (e.g., over 50% faster than end-to-end training on GOODCMNIST) while delivering competitive or superior OOD calibration.

Limitations and Future Work

  • Inference Overhead: G-$\Delta$UQ requires passing data through the anchored layers $K$ times at inference to compute variance, adding a modest computational cost compared to a standard single forward pass.
  • Hyperparameter Tuning: Choosing the optimal anchoring layer currently relies on empirical validation across different architectures.

Future Directions: The authors point toward automating the selection of the best anchoring layer and dynamically optimizing the parameters of the anchoring distribution using auxiliary calibration losses.

Summary updated

BibTeX
@inproceedings{trivedi2024accurate,
  author = {Puja Trivedi and Mark Heimann and Rushil Anirudh and Danai Koutra and Jayaraman J. Thiagarajan},
  title = {{Accurate and Scalable Estimation of Epistemic Uncertainty for Graph Neural Networks}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=ZL6yd6N1S2},
}
Figure