Downloads · 30 days
0
ARotting/hamiltonian-pocket
hamiltonian-pocket is a machine learning model from ARotting. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
Hamiltonian Pocket learns pendulum dynamics from state/derivative observations. The structured model predicts one scalar Hamiltonian and obtains time derivatives through the symplectic gradient. A parameter-matched ML…
Downloads · 30 days
0
Access
Public
Updated Jul 30, 2026
Repo size
36.5 KB
Likes
0
Public
Click a slice to open those files.
.safetensors36.5 KB · 58%
From the Hugging Face model README
Hamiltonian Pocket learns pendulum dynamics from state/derivative observations. The structured model predicts one scalar Hamiltonian and obtains time derivatives through the symplectic gradient. A parameter-matched MLP directly predicts the two derivatives. Both train on the same samples and use the same RK4 solver at test time.
The benchmark measures local derivative error, long-horizon state error, and drift in the true physical energy. It tests whether encoding conservative mechanics in the model helps trajectories remain physically plausible.
Both models trained for 3,000 steps on 20,000 states. Long-horizon evaluation used
128 new initial conditions, 400 RK4 steps, and dt=0.05.
| Metric | Hamiltonian network | Black-box vector field |
|---|---|---|
| Parameters | 4,417 | 4,482 |
| Held-out derivative MSE | 4.84e-6 | 1.13e-5 |
| Full-trajectory MSE | 49.00 | 119.89 |
| Final-state MSE | 201.84 | 439.03 |
| Final absolute true-energy drift | 2.95 | 343.11 |
The Hamiltonian inductive bias reduced final energy drift by about 116 times. It did not eliminate drift in the true physical energy: the learned scalar Hamiltonian is an approximation, and small derivative errors accumulate over 20 simulated seconds.
uv run python projects/hamiltonian-pocket/train.py