Bounded and Uniform Energy-based Out-of-distribution Detection for Graphs

Shenzhi Yang, Bin Liang, An Liu, Lin Gui, Xingkai Yao, Xiaofang Zhang

TL;DR

NODESAFE is a novel framework that significantly boosts the ability of Graph Neural Networks (GNNs) to detect node-level out-of-distribution (OOD) data. By introducing two simple yet effective optimization constraints that bound energy scores and mitigate "logit shifts," it achieves up to a 28.4% reduction in false positive rates compared to current state-of-the-art methods.

The Problem: Unbounded Energy Scores in GNNs

Graph Neural Networks are increasingly used in high-stakes domains like social network analysis and chemical modeling. A major security concern is their reliability when encountering out-of-distribution (OOD) data—nodes that differ significantly from the training set. If a GNN cannot tell it is looking at an anomaly, it might make a confident but disastrously wrong prediction.

Recent state-of-the-art methods, such as GNNSAFE, use "negative energy scores" to identify OOD nodes. The idea is to aggregate these scores across neighboring nodes to amplify the difference between in-distribution (ID) and OOD data. However, the authors of this paper discovered a critical flaw: these energy scores are unbounded.

Because scores can be infinitely large or small, a single "extreme" node can skew the scores of its entire neighborhood during aggregation. This leads to high variance and a massive overlap between the score distributions of ID and OOD nodes, making them nearly impossible to distinguish reliably. Furthermore, "logit shifts"—where adding a constant to the model's output doesn't change the classification but wildly changes the energy score—further destabilize detection.

Motivation: Reducing score variance leads to better separation between ID and OOD data.

The NODESAFE Solution

To address these vulnerabilities, the authors propose NODESAFE, which adds two specific regularization terms to the GNN's training objective to "tame" the energy scores:

  1. Boundedness Constraint ($L_{bound}$): This term constrains the 2-norm (the "length") of the logit vectors. By keeping the logits within a certain range, the resulting negative energy scores are mathematically forced to stay within predictable upper and lower bounds. This prevents extreme outliers from dominating the graph-wide score aggregation.
  2. Uniformity Constraint ($L_{uniform}$): This term minimizes the variance of the sum of logits. It acts as a stabilizer against logit shifts, ensuring that the model doesn't produce arbitrary score variations that have no impact on classification but ruin OOD detection.

By combining these constraints, NODESAFE forces the energy scores of ID and OOD nodes to converge toward their respective means, creating a much cleaner "gap" between the two groups.

Key Insights and Ideas

  • The Aggregation Trap: While aggregating scores across a graph is powerful for capturing context, it is a double-edged sword. Without bounds, "noise" from one extreme node propagates and pollutes the entire neighborhood.
  • Logit Shift is a Silent Killer: Standard training (like Cross-Entropy) is invariant to logit shifts, meaning the model doesn't care about the absolute scale of its outputs. Energy-based OOD detection, however, is highly sensitive to this scale. NODESAFE is the first to explicitly address this by bounding the 2-norm of logits.
  • Variance is the Enemy: The core realization is that OOD detection isn't just about finding a high score; it's about reducing the spread of scores so that the ID and OOD distributions do not overlap.
Visualization of 2D logits under different regularization terms.

Experimental Results

The researchers evaluated NODESAFE on five widely-used real-world datasets, including citation networks (Cora, Citeseer, Pubmed, ogbn-Arxiv) and social networks (Twitch-Explicit). They tested against various OOD types: Structure Manipulation, Feature Interpolation, and Label Leave-out.

NODESAFE consistently outperformed all baselines, including the previous SOTA, GNNSAFE:

  • FPR95 Improvement: In the "Structure Manipulation" scenario on the Cora dataset, NODESAFE reduced the FPR95 (False Positive Rate at 95% True Positive Rate—lower is better) by 28.4% without OOD exposure and 22.7% with it.
  • Robustness: The method showed significant gains across all three metrics (AUROC, AUPR, and FPR95) and across different GNN backbones like GCN, GAT, and JKNet.
  • Efficiency: Despite adding optimization terms, NODESAFE converges significantly faster than GNNSAFE (e.g., 61 epochs vs. 148 epochs on Cora) with negligible impact on inference time.

Limitations and Future Work

The authors note that while NODESAFE excels at detecting structural and feature-based OOD data, its performance on temporal splits (like in the Arxiv dataset, where OOD nodes are papers from later years) is more modest. They hypothesize this is because the energy scores for these "near-OOD" samples are naturally closer to the ID distribution. Future work will likely focus on improving detection for these subtle temporal shifts and ensuring that OOD detection remains robust even when the underlying supervised classification performance isn't perfect.

Summary updated

BibTeX
@inproceedings{yang2024bounded,
  author = {Shenzhi Yang and Bin Liang and An Liu and Lin Gui and Xingkai Yao and Xiaofang Zhang},
  title = {{Bounded and Uniform Energy-based Out-of-distribution Detection for Graphs}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=mjh7AOWozN},
}
Figure