Re-Hamiltonian Generative Networks

Carles Balsells Rodas, Oleguer Canal, Federico TaschinRC 2021

TL;DR

This paper tackles the challenge of learning the underlying physics of systems directly from visual observations, specifically focusing on Hamiltonian dynamics. The authors successfully reproduce and extend the "Re-Hamiltonian Generative Networks" (HGN) model, demonstrating its ability to learn system dynamics and generate future states, though with notable challenges in accurately predicting unseen future frames.

What Problem Does This Paper Address?

Understanding and predicting the behavior of physical systems is a fundamental scientific endeavor. Traditionally, this involves deriving explicit mathematical models (like Newton's laws or Hamiltonian mechanics) and then solving them. However, for complex systems or when direct observation is the primary data source, deriving these explicit models can be difficult or impossible. The paper addresses the problem of learning these underlying physical dynamics, specifically Hamiltonian dynamics, directly from high-dimensional observations (like sequences of images) without requiring prior knowledge of the system's explicit equations. The goal is to create a generative model that can not only reconstruct observed system evolution but also predict future states and even run simulations backward or at different speeds.

Methods

The core of the paper is the re-implementation and extension of the Hamiltonian Generative Network (HGN) architecture. The HGN consists of several key components:

  • Encoder: This network takes a sequence of input frames and maps them to a latent representation of the system's abstract position and momentum. It uses a diagonal Gaussian distribution for this mapping, employing the reparametrization trick for sampling.
  • Transformer: This component transforms the sampled latent variable into a lower-dimensional initial state, effectively extracting the abstract position and momentum.
  • Hamiltonian Network: This network learns the system's Hamiltonian function, which is crucial for predicting future states according to Hamiltonian dynamics. It uses SoftPlus activations to enable the computation of second-order derivatives required for training.
  • Decoder: This network takes the abstract position and decodes it back into an RGB image, allowing for visual reconstruction of the system's state.

The training objective is a combination of two terms: a reconstruction loss (ensuring the generated images match the observed ones) and a KL divergence loss (encouraging the latent distribution to be close to a standard Gaussian). The authors also explore different integrators (Euler, Runge-Kutta, Leapfrog, and Yoshida) to evolve the system's state in time, noting that symplectic integrators like Leapfrog and Yoshida are theoretically better at preserving the Hamiltonian's properties.

Datasets

The authors re-implemented datasets for four physical systems originally presented in [14]:

  • Mass-spring system
  • Simple pendulum
  • Two-/three-body problem

Additionally, they introduced two new physical systems to test the model's generalization capabilities:

  • Damped harmonic oscillator (introducing dissipation)
  • Double pendulum (introducing a non-separable Hamiltonian, leading to more chaotic behavior)

Data generation involved sampling initial conditions, simulating trajectories using ground-truth Hamiltonian dynamics and SciPy's ODE solver, adding Gaussian noise, and rendering 32x32 image observations. They generated 50,000 training and 10,000 testing samples for each system.

Key Insights and Ideas

  • Learning Physics from Pixels: The HGN demonstrates a remarkable ability to learn the underlying physics of systems directly from visual input, bypassing the need for explicit physical equations.
  • Generative Capabilities: The model can not only reconstruct observed sequences but also generate new ones, and importantly, it can manipulate the time evolution (speeding up or slowing down) by adjusting the integrator's time step.
  • The Challenge of "Unseen" Predictions: While reconstructing the input sequence (as an autoencoder) yields comparable results to the original paper, predicting entirely new frames based on a few initial inputs proves significantly more challenging, leading to much higher errors.
  • GECO's Brittleness: The GECO algorithm, intended to dynamically balance reconstruction and KL divergence losses, was found to be highly sensitive to hyperparameters and resulted in unstable training. This led the authors to revert to simpler methods like a fixed Lagrange multiplier.
  • Visual Cues vs. Underlying Dynamics: The authors hypothesize that larger visual elements and faster dynamics in systems like the mass-spring and pendulum might lead to higher pixel MSE, even if the underlying physics are learned more effectively, compared to systems with smaller elements like the two-/three-body problem.

Key Results

  • Reconstruction Accuracy: When trained as an autoencoder (reconstructing the input sequence), the re-implemented HGN achieved comparable average pixel MSE (around 30% absolute relative error) to the original paper.
  • 5-Frame Inference Performance: When trained to predict future frames from only the first 5 input frames, the model's performance degraded significantly, with an average absolute error of 107%.
  • Integrator Performance: Euler integration provided a fast and reasonably reliable reconstruction. Higher-order symplectic integrators like Leapfrog and Yoshida offered better performance but at the cost of increased computation time. Yoshida integrator showed the best performance.
  • New Environments: The HGN showed high reliability in reconstructing the damped harmonic oscillator but struggled with the more chaotic trajectories of the double pendulum, though it still performed better than on mass-spring and pendulum systems.

Limitations and Future Work

  • Reconstruction of Unseen Frames: The most significant limitation is the poor performance in predicting future frames when only a few initial frames are provided. The authors' intuition points to potential issues with hyperparameter tuning, implementation details, or the inherent difficulty of extrapolating dynamics.
  • Hamiltonian Invariance: While the model learns dynamics, the learned Hamiltonian does not strictly remain constant throughout the system evolution, suggesting it might be learning a related but not identical representation of the physics.
  • GECO Optimization: The difficulty in tuning the GECO algorithm for stable and effective optimization remains a challenge.
  • Future Work: The authors suggest exploring smaller network architectures, testing on more complex and realistic environments, investigating transfer learning between environments, and applying generative models to model-based reinforcement learning for more efficient agent training. Further experiments are also needed to fully understand the behavior of symplectic integrators and ensure their faithful implementation.

Summary updated

BibTeX
@inproceedings{rodas2021re,
  author = {Carles Balsells Rodas and Oleguer Canal and Federico Taschin},
  title = {{Re-Hamiltonian Generative Networks}},
  booktitle = {RC},
  year = {2021},
  url = {https://openreview.net/forum?id=Zszk4rXgesL},
}
Figure