Introduction
Graph Neural Networks (GNNs) typically struggle with "extrapolation"—the ability to perform on graphs much larger than those seen during training. While classical algorithms like Dijkstra's are size-invariant, standard GNNs are limited by a fixed number of message-passing layers. This paper proposes a recurrent GNN architecture that, through specific structural and regularization techniques, can be trained on graphs of just 10 nodes and generalize to graphs of 10,000 nodes by simply running more iterations at inference time.
Architecture: Recurrence and Persistence
The core of the approach is a Recurrent GNN, where the same layer is applied repeatedly. This allows the model to scale its computation depth at inference time without increasing parameter count. To ensure the model remains focused on the original task over many iterations, the authors introduce Skip Connections to the Input. Unlike standard residual connections, this mechanism re-injects the initial problem features into every iteration of the recurrent layer. Additionally, the use of edge-based MLPs (as in the RecGRU-E variant) allows for more nuanced control over information propagation.
Stability through Regularization
A significant challenge in recurrent networks is maintaining numerical stability over thousands of iterations. The authors found that recurrence alone is insufficient; without constraints, internal node embeddings tend to diverge. To solve this, they apply State Regularization (L2 Loss), which penalizes large embedding values and encourages the network to find stable fixed-point solutions.
Experimental results on algorithmic benchmarks like Path Finding and Distance show that this regularization is critical for long-term stability. As shown in the figure below, models without L2 regularization experience a sharp decline in accuracy after approximately 100 rounds, whereas regularized models maintain near-perfect performance even up to 10,000 rounds.
Key Results and Conclusion
The RecGRU-E model achieved an F1 score of 0.97 on 10,000-node graphs for the Distance task, despite being trained on only 10 nodes. This demonstrates that GNNs can indeed learn size-invariant algorithmic logic when equipped with the right architectural priors. Future work will focus on implementing learned halting criteria to allow the model to dynamically determine the necessary number of iterations for a given graph size, further bridging the gap between neural networks and symbolic reasoning.
Summary updated