Hamiltonian Neural Networks
Sam Greydanus, Misko Dzamba, Jason Yosinski
TL;DR
The paper proposes Hamiltonian Neural Networks (HNNs) that learn a neural Hamiltonian H_theta(q,p) to enforce exact energy conservation in dynamics, addressing the lack of physics priors in standard neural nets. By using in-graph gradients of H_theta to match time derivatives, HNNs yield energy-preserving, reversible dynamics that generalize across tasks. Across ideal mass-spring, pendulum, real pendulum, two-body, and pixel-based pendulum scenarios, HNNs match baseline performance on pointwise losses but dramatically outperform on energy conservation, demonstrating scalability and robustness to high-dimensional observations. The work offers a general, unsupervised framework for embedding conservative physics into neural models and enables energy-based counterfactuals and precise reversible simulations.
Abstract
Even though neural networks enjoy widespread use, they still struggle to learn the basic laws of physics. How might we endow them with better inductive biases? In this paper, we draw inspiration from Hamiltonian mechanics to train models that learn and respect exact conservation laws in an unsupervised manner. We evaluate our models on problems where conservation of energy is important, including the two-body problem and pixel observations of a pendulum. Our model trains faster and generalizes better than a regular neural network. An interesting side effect is that our model is perfectly reversible in time.
