arXiv:2503.19173cs.LGcs.DS2025-03被引 10

让神经网络学会像经典算法一样外推,解决图路径问题

Graph neural networks extrapolate out-of-distribution for shortest paths

  • 用动态规划思想设计神经网络结构,使其逼近贝尔曼-福特算法
  • 训练后可精确求解任意大小图的最短路径,误差随训练精度线性下降
  • 适合需要可靠外推能力的现实图数据场景,如交通、通信网络

尽管神经网络应用广泛,但在分布外(OOD)情况下的泛化能力仍不足。当图神经网络(GNNs)在小规模图上训练后需应用于大规模真实图时,这一问题尤为关键。本文提出通过神经算法对齐框架提升模型的外推能力,即设计模仿经典算法(如动态规划)的神经架构。我们严格分析了该方法在最短路径问题上的表现,证明:在小规模最短路径样本上,以稀疏性正则化损失为目标训练的GNN,会精确实现贝尔曼-福特(Bellman-Ford, BF)算法;若训练误差为ε,其实际实现误差为O(ε)。因此,即使训练数据有限,这些模型也能保证对任意规模图的最短路径问题实现外推。实验结果验证了理论,表明梯度下降训练的神经网络可有效最小化该损失并实现外推。

原文摘要 · Abstract (English)

Neural networks (NNs), despite their success and wide adoption, still struggle to extrapolate out-of-distribution (OOD), i.e., to inputs that are not well-represented by their training dataset. Addressing the OOD generalization gap is crucial when models are deployed in environments significantly different from the training set, such as applying Graph Neural Networks (GNNs) trained on small graphs to large, real-world graphs. One promising approach for achieving robust OOD generalization is the framework of neural algorithmic alignment, which incorporates ideas from classical algorithms by designing neural architectures that resemble specific algorithmic paradigms (e.g. dynamic programming). The hope is that trained models of this form would have superior OOD capabilities, in much the same way that classical algorithms work for all instances. We rigorously analyze the role of algorithmic alignment in achieving OOD generalization, focusing on graph neural networks (GNNs) applied to the canonical shortest path problem. We prove that GNNs, trained to minimize a sparsity-regularized loss over a small set of shortest path instances, exactly implement the Bellman-Ford (BF) algorithm for shortest paths. In fact, if a GNN minimizes this loss within an error of $ε$, it implements the BF algorithm with an error of $O(ε)$. Consequently, despite limited training data, these GNNs are guaranteed to extrapolate to arbitrary shortest-path problems, including instances of any size. Our empirical results support our theory by showing that NNs trained by gradient descent are able to minimize this loss and extrapolate in practice.

图神经网络外推能力最短路径算法对齐

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。