Deconstructing the Inductive Biases of Hamiltonian Neural Networks

Nate Gruver, Marc Anton Finzi, Samuel Don Stanton, Andrew Gordon Wilson

In recent years, "physics-informed" machine learning has exploded in popularity. Models like Hamiltonian Neural Networks (HNNs) and Lagrangian Neural Networks (LNNs) use deep learning to bake physical laws—like the conservation of energy—directly into their architecture. While these models excel at predicting the motion of simple, idealized systems like pendulums, they often struggle when applied to the "messy" real world of robotics and reinforcement learning, where energy is lost to friction and systems involve complex contacts.

This raises a fundamental question: Which specific "physics" biases are actually doing the heavy lifting in these models? Is it the symplectic geometry? The strict energy conservation? Or something much simpler? By systematically deconstructing these biases, researchers aim to build models that are as robust as HNNs but flexible enough for practical engineering tasks.

Expectation vs. Reality in Physics-Informed Models

To understand what makes HNNs tick, the researchers performed a systematic ablation study of the inductive biases found in these networks. They compared standard Neural Ordinary Differential Equations (NODEs) against several variations, testing the impact of symplectic regularization, energy conservation, second-order bias, and functional complexity.

Expectation vs. Reality of Inductive Biases

The findings challenge conventional wisdom in the field:

  • Energy conservation is a red herring: Surprisingly, HNNs are no better at conserving a system's true energy than standard NODEs when both are trained to the same level of accuracy. The "conservation" in HNNs applies to their learned energy function, which can drift significantly from reality.
  • Symplecticity doesn't help generalization: Adding a penalty for violating symplectic structure (a core feature of Hamiltonian mechanics) provided negligible benefits and sometimes even hurt performance.
  • Hamiltonians simplify the math, not the physics: HNNs perform better in complex coordinate systems (like joint angles) because the scalar Hamiltonian function is mathematically simpler to represent with a neural network than the full vector field of the dynamics.

The "Secret Sauce": Second-Order Structure

If energy conservation and symplectic geometry aren't the primary drivers of HNN performance, what is? The single most important factor is the assumption that the system is second-order—meaning position changes through velocity, and forces change velocity.

When this simple bias is added to a standard Neural ODE (creating a model termed NODE + SO), it accounts for almost all the performance gains traditionally attributed to HNNs. The model simply assumes $dq/dt = v$ and learns to predict $dv/dt$.

Energy Violation vs. Rollout Error

As shown in the performance clustering above, explicitly structuring the ODE to model acceleration ($d^2q/dt^2$) rather than just the first derivative of the state allows the much simpler NODE + SO model to match the energy violation and rollout error metrics of complex HNNs.

Performance Across Complex Environments

The researchers evaluated these models across a spectrum of complexity, from synthetic physics (chain and spring pendulums) to non-conservative systems (pendulums with drag) and complex control tasks (MuJoCo environments like HalfCheetah, Hopper, and Swimmer).

  • Matching HNNs on Toy Systems: On energy-conserving toy systems, the simplified NODE + SO model matched or exceeded the performance of HNNs.
  • Superiority in MuJoCo: In complex MuJoCo environments, HNNs performed poorly because their rigid physics biases made it difficult to fit the training data. NODE + SO, however, significantly outperformed both HNNs and standard NODE baselines.
  • Computational Efficiency: The NODE + SO approach achieves the performance of more complex models while using a fraction of the parameters and computation.

Conclusion and Future Directions

By stripping away restrictive physics constraints and simply modeling acceleration directly, the authors successfully demystified the "physics magic" of Hamiltonian Neural Networks. While HNNs still maintain a slight edge in systems with extremely high "functional complexity" (where the Hamiltonian is much simpler than the vector field), the NODE + SO model proves to be a vastly superior choice for complex, real-world robotic simulations.

Future work may explore how these second-order biases behave in latent space dynamics, where models must learn both the coordinates and the physics simultaneously from raw pixels. Furthermore, the NODE + SO framework shows immense promise as a powerful, drop-in replacement for transition models currently used in Model-Based Reinforcement Learning (MBRL).

Summary updated

BibTeX
@inproceedings{gruver2022deconstructing,
  author = {Nate Gruver and Marc Anton Finzi and Samuel Don Stanton and Andrew Gordon Wilson},
  title = {{Deconstructing the Inductive Biases of Hamiltonian Neural Networks}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=EDeVYpT42oS},
}
Figure