crozol/neural-odes-hnn-demo
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 preservesH_θ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
- 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).
- 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.
