Table of Contents
Fetching ...

Hamiltonian Generative Networks

Peter Toth, Danilo Jimenez Rezende, Andrew Jaegle, Sébastien Racanière, Aleksandar Botev, Irina Higgins

TL;DR

This work introduces the Hamiltonian Generative Network (HGN), a model that learns Hamiltonian dynamics directly from pixel observations and enables reversible, controllable rollouts as well as a density-modelling variant (NHF) based on Hamiltonian flows. The architecture combines an inference network, a Hamiltonian transition network, and a decoder to infer abstract phase-space states and simulate their evolution via Hamilton's equations with a symplectic leapfrog integrator. Empirical results on mass-spring, pendulum, and multi-body systems show that HGN significantly outperforms the Hamiltonian Neural Network baselines and supports robust, energy-conserving dynamics; NHF demonstrates expressive density modelling with interpretable potential landscapes and competitive efficiency. The approach bridges physics-inspired dynamics with deep generative modelling, offering practical benefits for long-horizon prediction, reversible inference, and multimodal density estimation in dynamical systems.

Abstract

The Hamiltonian formalism plays a central role in classical and quantum physics. Hamiltonians are the main tool for modelling the continuous time evolution of systems with conserved quantities, and they come equipped with many useful properties, like time reversibility and smooth interpolation in time. These properties are important for many machine learning problems - from sequence prediction to reinforcement learning and density modelling - but are not typically provided out of the box by standard tools such as recurrent neural networks. In this paper, we introduce the Hamiltonian Generative Network (HGN), the first approach capable of consistently learning Hamiltonian dynamics from high-dimensional observations (such as images) without restrictive domain assumptions. Once trained, we can use HGN to sample new trajectories, perform rollouts both forward and backward in time and even speed up or slow down the learned dynamics. We demonstrate how a simple modification of the network architecture turns HGN into a powerful normalising flow model, called Neural Hamiltonian Flow (NHF), that uses Hamiltonian dynamics to model expressive densities. We hope that our work serves as a first practical demonstration of the value that the Hamiltonian formalism can bring to deep learning.

Hamiltonian Generative Networks

TL;DR

This work introduces the Hamiltonian Generative Network (HGN), a model that learns Hamiltonian dynamics directly from pixel observations and enables reversible, controllable rollouts as well as a density-modelling variant (NHF) based on Hamiltonian flows. The architecture combines an inference network, a Hamiltonian transition network, and a decoder to infer abstract phase-space states and simulate their evolution via Hamilton's equations with a symplectic leapfrog integrator. Empirical results on mass-spring, pendulum, and multi-body systems show that HGN significantly outperforms the Hamiltonian Neural Network baselines and supports robust, energy-conserving dynamics; NHF demonstrates expressive density modelling with interpretable potential landscapes and competitive efficiency. The approach bridges physics-inspired dynamics with deep generative modelling, offering practical benefits for long-horizon prediction, reversible inference, and multimodal density estimation in dynamical systems.

Abstract

The Hamiltonian formalism plays a central role in classical and quantum physics. Hamiltonians are the main tool for modelling the continuous time evolution of systems with conserved quantities, and they come equipped with many useful properties, like time reversibility and smooth interpolation in time. These properties are important for many machine learning problems - from sequence prediction to reinforcement learning and density modelling - but are not typically provided out of the box by standard tools such as recurrent neural networks. In this paper, we introduce the Hamiltonian Generative Network (HGN), the first approach capable of consistently learning Hamiltonian dynamics from high-dimensional observations (such as images) without restrictive domain assumptions. Once trained, we can use HGN to sample new trajectories, perform rollouts both forward and backward in time and even speed up or slow down the learned dynamics. We demonstrate how a simple modification of the network architecture turns HGN into a powerful normalising flow model, called Neural Hamiltonian Flow (NHF), that uses Hamiltonian dynamics to model expressive densities. We hope that our work serves as a first practical demonstration of the value that the Hamiltonian formalism can bring to deep learning.

Paper Structure

This paper contains 26 sections, 21 equations, 13 figures, 2 tables.

Figures (13)

  • Figure 1: The Hamiltonian manifold hypothesis: natural images lie on a low-dimensional manifold in pixel space, and natural image sequences (such as one produced by watching a two-body system, as shown in red) correspond to movement on the manifold according to Hamiltonian dynamics.
  • Figure 2: Hamiltonian Generative Network schematic. The encoder takes a stacked sequence of images and infers the posterior over the initial state. The state is rolled out using the learnt Hamiltonian. Note that we depict Euler updates of the state for schematic simplicity, while in practice this is done using a leapfrog integrator. For each unroll step we reconstruct the image from the position ${\bm{q}}$ state variables only and calculate the reconstruction error.
  • Figure 3: A: standard normalising flow, where the invertible function $f_i$ is implemented by a neural network. B: Hamiltonian flows, where the initial density is transformed using the learned Hamiltonian dynamics. Note that we depict Euler updates of the state for schematic simplicity, while in practice this is done using a leapfrog integrator.
  • Figure 4: A schematic representation of NHF which can perform expressive density modelling by using the learned Hamiltonians as normalising flows. Note that we depict Euler updates of the state for schematic simplicity, while in practice this is done using a leapfrog integrator.
  • Figure 5: Ground truth Hamiltonians and samples from generated datasets for the ideal pendulum, mass-spring, and two- and three-body systems used to train HGN.
  • ...and 8 more figures