CoolFace
Apppublic

crozol/neural-odes-hnn-demo

sourceHugging Facemitupdated 4mo agoView on Hugging Face
0likes
App README

Neural ODEs · Hamiltonian prior vs. unconstrained MLP

Interactive Streamlit demo of a physics-informed ablation. Two Neural ODEs learn the right-hand side of a conservative 2D system from one short noisy trajectory:

  • an unconstrained MLP vector field dy/dt = f_θ(y), and
  • a Hamiltonian Neural Network (Greydanus et al., 2019) that parametrises a scalar H_θ and integrates its symplectic gradient, so every trajectory it produces preserves H_θ by construction.

Drag the horizon slider to roll both learned ODEs forward past the training window and watch the system's conserved quantity H. The MLP lets it drift; the HNN keeps it almost flat — on Lotka-Volterra the documented drift drops from ≈ 7.9 % to ≈ 2.4 % at the same parameter budget, and on the simple harmonic oscillator the HNN drift (≈ 0.9 %) is bounded by the solver's truncation floor, not by the architecture.

How to use the demo

  1. 1.Pick a system in the sidebar — Lotka-Volterra (the non-trivial case, Hamiltonian in log-coordinates) or the simple harmonic oscillator (the clean canonical limit).
  2. 2.Drag the horizon slider (in multiples of the training window). The phase orbit and the H(t) curve update live; the metric tiles report the invariant drift of each model and the reduction factor.

The damped pendulum from the full project is intentionally excluded: it is dissipative, so a pure Hamiltonian prior does not apply.

Full project

This Space ships only the Streamlit demo and the four pre-trained checkpoints. The complete project — training pipeline, curriculum, 5-seed error bars, the full lab-guide README and tests — lives at:

  • Code: https://github.com/crozol/02-neural-odes
  • Portfolio page: https://crozol.github.io/projects/02-neural-odes.html

References

  • Chen, R. T. Q., Rubanova, Y., Bettencourt, J. & Duvenaud, D. (2018). Neural Ordinary Differential Equations. NeurIPS. arXiv:1806.07366.
  • Greydanus, S., Dzamba, M. & Yosinski, J. (2019). Hamiltonian Neural Networks. NeurIPS. arXiv:1906.01563.