Node Embedding from Neural Hamiltonian Orbits in Graph Neural Networks

Qiyu Kang, Kai Zhao, Yang Song, Sijie Wang, Wee Peng Tay · DOI

Introduction

Graph Neural Networks (GNNs) have become the standard for learning representations on graph-structured data. However, a significant limitation of traditional GNNs is their reliance on fixed geometric priors, typically Euclidean space. While Euclidean embeddings work well for certain graphs, many real-world datasets exhibit non-Euclidean structures. For instance, hierarchical or tree-like networks are more naturally represented in hyperbolic space, while others may possess spherical or mixed geometries.

Existing "geometry-aware" models often require practitioners to manually select a specific manifold (e.g., a Poincaré ball or a Lorentz model) before training. This is problematic for complex datasets where the underlying geometry is unknown or varies across different regions of the graph. This paper introduces HamGNN, a framework that treats node feature updates as trajectories—or orbits—within a physical system governed by Hamiltonian mechanics, allowing the model to learn the optimal geometry directly from the data.

Methodology: Hamiltonian Dynamics for Feature Evolution

The core of HamGNN is the conceptualization of node embeddings as positions within a "phase space." In classical mechanics, the state of a system is defined by its position $q$ and momentum $p$. The evolution of this system over time is governed by the Hamiltonian function $H(q, p)$, representing the total energy.

1. Phase Space and Hamiltonian Equations

In HamGNN, each node $i$ is assigned a position vector $q_i$ (representing its features) and a learnable momentum vector $p_i$. The update rule for these features is derived from Hamilton’s equations: $$\dot{q} = \frac{\partial H}{\partial p}, \quad \dot{p} = -\frac{\partial H}{\partial q}$$ By solving these differential equations, the model evolves node features along "Hamiltonian orbits." This approach generalizes the concept of geodesics on a manifold; instead of being restricted to a fixed curvature, the path is determined by a learnable Hamiltonian.

2. Learnable Metric Tensors

A key innovation is the use of a learnable metric tensor $g$. In differential geometry, the metric tensor defines the local properties of the space, such as distance and volume. HamGNN learns this metric based on the local neighborhood of each node, allowing the "shape" of the embedding space to adapt dynamically. This enables the model to handle "mixed" geometries where one part of the graph might be hyperbolic while another is Euclidean.

3. Model Architecture

The HamGNN pipeline consists of three main stages:

  1. Feature Compression: Raw input features are projected into a lower-dimensional latent space.
  2. Hamiltonian Evolution: Node features are evolved through multiple "Hamiltonian layers" using an ODE solver (such as the Euler method).
  3. Neighborhood Aggregation: Information is shared between connected nodes to capture the graph's topological structure.

Experimental Evaluation

The authors evaluated HamGNN against a variety of baselines, including GCN, GAT, and specialized hyperbolic models like HGCN.

Datasets

The evaluation spanned several categories:

  • Citation Networks: Cora, Citeseer, and Pubmed.
  • Hierarchical Graphs: Disease and Airport datasets, which exhibit high hyperbolicity.
  • Mixed Geometry Benchmarks: To test the model's adaptability, the authors created synthetic "mixed" datasets (e.g., Airport+Cora) where different subgraphs possess distinct geometric properties.
  • Large-Scale Graphs: Ogbn-Arxiv and Ogbn-Products from the Open Graph Benchmark.

Key Insights and Results

Adaptability and Performance

HamGNN consistently matched or outperformed state-of-the-art GNNs across diverse tasks. Notably, on mixed geometry datasets, HamGNN demonstrated a significant performance advantage, confirming its ability to learn heterogeneous structures that fixed-manifold models struggle to capture. In link prediction tasks, the model achieved near-perfect ROC scores (up to 99.99%) on datasets like Airport and Citeseer.

Resilience to Over-Smoothing

Deep GNNs often suffer from over-smoothing, where node features converge to a single point as the number of layers increases. Because Hamiltonian systems are conservative—meaning they preserve the "energy" of the features—HamGNN is naturally resistant to this phenomenon. The authors successfully trained models with up to 20 layers without the typical performance collapse.

Efficiency

Despite the inclusion of ODE solvers, HamGNN remains computationally competitive. It exhibited faster training times than several complex hyperbolic GNNs (such as HGCN and GIL), making it a viable candidate for large-scale applications.

Conclusion and Future Directions

HamGNN represents a shift from choosing a geometry to learning one. By leveraging the stability and flexibility of Hamiltonian mechanics, the model provides a robust framework for node embedding across varied graph structures.

Future work may involve the use of symplectic integrators—numerical solvers specifically designed to preserve the properties of Hamiltonian systems—to further enhance stability. Additionally, while HamGNN excels in homophilic settings, extending the framework to better handle heterophilic graphs (where connected nodes are dissimilar) remains an open area for research.

Summary updated

BibTeX
@inproceedings{kang2023node,
  author = {Qiyu Kang and Kai Zhao and Yang Song and Sijie Wang and Wee Peng Tay},
  title = {{Node Embedding from Neural Hamiltonian Orbits in Graph Neural Networks}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=11UsDUxmZi1},
}
Figure