---
title: Hamiltonian Neural Networks
url: https://www.emergentmind.com/topics/hamiltonian-neural-networks
type: topic
---

# Hamiltonian Neural Networks

Searching arXiv for the cited Hamiltonian Neural Network papers to anchor the article in the research literature.
{"query":"Hamiltonian Neural Networks Greydanus 1906.01563 high-dimensional dynamics 2008.04214 separable Hamiltonian Neural Networks 2309.01069 adaptable Hamiltonian neural networks 2102.13235 symplectic learning 2106.11753 deconstructing inductive biases 2202.04836", "max_results": 10}
Hamiltonian Neural Networks (HNNs) are neural models for dynamical systems that learn a scalar Hamiltonian and recover time evolution by differentiating that scalar through Hamilton’s equations, rather than learning the vector field directly. In canonical coordinates \(z=(q,p)\), this constrains the learned dynamics to Hamiltonian form, makes the model’s continuous-time flow conserve its learned Hamiltonian, and places HNNs within the broader class of structure-preserving or “gray-box” methods in scientific machine learning [1906.01563][2203.00128]. Since their introduction, HNNs have developed from a model for conservative mechanical systems into a broader research program that includes separable, parameter-cognizant, symmetry-aware, constrained, port-Hamiltonian, geometric reduced-order, and backpropagation-free variants [2309.01069][2102.13235][2301.07928][2412.03018][2502.14432][2507.15678][2411.17511].

## 1. Origins and research context

The modern HNN literature was catalyzed by “Hamiltonian Neural Networks” [1906.01563], which formulated the basic idea of representing dynamics through a learned scalar energy-like function. That paper framed HNNs as a response to a recurrent failure mode of ordinary neural dynamics models: they can fit short-term trajectories while drifting over long horizons because they have no built-in reason to preserve invariants. In the original formulation, the model “trains faster and generalizes better than a regular neural network,” and the learned flow is “perfectly reversible in time” in the continuous Hamiltonian sense [1906.01563].

The original empirical program combined idealized and observational settings. The paper studied an ideal mass-spring, an ideal pendulum, a real pendulum dataset, a two-body gravitational problem, and a pendulum-from-pixels setting with a latent autoencoder representation. On the two-body problem, both train and test losses were reported as about an order of magnitude lower than the baseline, and energy MSE was lower by several orders of magnitude; in the pixel pendulum experiment, the reported energy metric was \(9.3\times 10^{-3}\) for the baseline versus \(0.15\times 10^{-3}\) for the HNN [1906.01563].

A later methodological survey organized the expanding field along four overlapping directions: generalized Hamiltonian systems, symplectic integration, generalized input forms, and extended problem settings [2203.00128]. This framing captures a central feature of the literature: HNNs are no longer a single model class but a family of neural dynamical systems that retain the core idea of learning a generator rather than directly regressing motion.

## 2. Canonical formulation and standard training objective

The standard HNN assumes a Hamiltonian system in canonical coordinates. With generalized coordinates \(q\), conjugate momenta \(p\), and Hamiltonian \(H(q,p)\), the dynamics are
\[
\dot q = \frac{\partial H}{\partial p}, \qquad \dot p = -\frac{\partial H}{\partial q}.
\]
In vector form, with \(z=(q,p)\), one writes
\[
\dot z = J \nabla H(z),
\]
where \(J\) is the canonical symplectic matrix [1906.01563][2203.00128].

An HNN replaces the unknown Hamiltonian by a neural scalar field \(H_\theta(q,p)\). The network does not directly output \((\dot q,\dot p)\); instead, the vector field is induced by automatic differentiation,
\[
\dot q_\theta = \frac{\partial H_\theta}{\partial p}, \qquad \dot p_\theta = -\frac{\partial H_\theta}{\partial q}.
\]
Training is supervised at the level of derivatives. In the original HNN formulation, the loss is
\[
\mathcal{L}_{\text{HNN}} =
\left\| \frac{\partial H_\theta}{\partial p} - \dot q \right\|_2
+
\left\| \frac{\partial H_\theta}{\partial q} + \dot p \right\|_2,
\]
with derivatives either given analytically or approximated from trajectories by finite differences [1906.01563]. In the high-dimensional formulation of Miller et al., the same idea is written componentwise as
\[
C \sim \sum_{n=1}^d \left(\dot q_n - \frac{\partial H_\theta}{\partial p_n}\right)^2
+
\sum_{n=1}^d \left(\dot p_n + \frac{\partial H_\theta}{\partial q_n}\right)^2
\]
[2008.04214].

This construction implies a structural conservation law for the learned model. Along trajectories of the learned continuous-time system,
\[
\frac{dH_\theta}{dt}
=
\nabla H_\theta(z)^\top J \nabla H_\theta(z)
=
0,
\]
because \(J\) is antisymmetric [1906.01563]. The result is exact conservation of the learned Hamiltonian under the model’s own continuous-time flow, not merely conservation encouraged by a penalty term. Standard neural ODE-style baselines, by contrast, learn a vector field \(f_\theta(z)\) directly and do not inherit this structure [2203.00128].

## 3. Inductive bias, geometric interpretation, and competing explanations

One influential explanation of HNN performance is the “map building perspective” of Miller et al. A conventional feed-forward dynamics model maps the state to the tangent space, that is, to derivative components. An HNN instead maps the state to a single scalar energy surface, and the derivatives are recovered as gradients of that surface. For the one-dimensional harmonic oscillator, the ideal HNN map is the paraboloidal surface
\[
H = \frac{q^2+p^2}{2},
\]
whereas the standard network learns separate planes for derivative components [2008.04214]. On this view, the burden of learning grows more slowly for HNNs because the representation is organized around a single generating function rather than many outputs.

This argument becomes stronger in higher dimensions in the same paper. On a one-dimensional linear oscillator, the HNN conserves energy within about \(0.01\%\), whereas the conventional neural network loses almost \(10\%\) energy over \(0<t<16\pi\). In higher-dimensional tests, HNN forecasting is reported as up to about \(4\) times better than a matched neural baseline for linear oscillators, up to about \(20\) times better for quartic oscillators, and up to about \(9\) times better for a coupled bistable chain; the six-dimensional linear-oscillator error scaling is fit empirically by
\[
\frac{\delta E}{E} \sim 0.12\,N^{-0.22}
\]
[2008.04214].

A different line of work disputes the usual interpretation of these gains. “Deconstructing the Inductive Biases of Hamiltonian Neural Networks” argues that, contrary to conventional wisdom, the improved generalization of HNNs is often due to modeling acceleration directly and avoiding artificial complexity from the coordinate system, rather than symplectic structure or energy conservation [2202.04836]. In that account, the practically decisive bias is second-order mechanics. The paper further reports that true-energy violation correlates strongly with rollout error, and that directly regularizing a neural ODE toward symplecticity yields little to no consistent benefit [2202.04836].

The literature therefore contains a substantive conceptual disagreement. One strand emphasizes scalar-generator learning, symplectic structure, and conservation as the dominant source of HNN performance [1906.01563][2008.04214]. Another argues that much of the apparent advantage comes from second-order structure and coordinate simplification, with exact Hamiltonianity being beneficial only in settings where the system and representation genuinely match the assumptions [2202.04836]. This disagreement has become a central point in the interpretation of HNNs.

## 4. Discrete-time learning and the role of symplectic numerics

A separate line of research argues that the numerical integrator embedded in training is not an implementation detail but part of what the model learns. “Deep Hamiltonian networks based on symplectic integrators” shows that the network target in a discretized HNet is the Hamiltonian of an inverse modified equation determined by the chosen integrator; non-symplectic integrators cannot guarantee the existence of network targets, whereas symplectic HNets possess network targets and the difference between those targets and the original Hamiltonians depends on the accuracy order of the integrator [2004.13830]. In the paper’s experiments, the trained network matches the modified Hamiltonian much more closely than the original Hamiltonian.

“Symplectic Learning for Hamiltonian Neural Networks” takes this idea further by reinterpreting the standard finite-difference HNN loss as a forward-Euler training rule. The paper argues that this inserts a non-symplectic discretization into learning and creates an artificial lower bound on the loss. It replaces the usual objective by a symplectic loss based on symplectic Euler or implicit midpoint,
\[
\mathcal L_{\mathrm{SHNN}} =
\left\|
\frac{y_1-y_0}{h}
-
J^{-1}\nabla \hat H\bigl(s(y_0,y_1)\bigr)
\right\|_{L^2}^2,
\]
with \(s(y_0,y_1)\) chosen according to the symplectic scheme. The resulting theory guarantees the existence of an exact modified Hamiltonian \(\tilde H\) that the network can learn, and derives post-training corrections that reconstruct the true Hamiltonian from discretized data up to arbitrary order. For implicit midpoint, the leading correction is
\[
H = \tilde H - \frac{h^2}{24}\, \nabla^2 \tilde H\bigl(J^{-1}\nabla \tilde H,\;J^{-1}\nabla \tilde H\bigr) +\mathcal O(h^4)
\]
[2106.11753].

Recent work extends this symplectic viewpoint to noisy trajectory identification for generalized non-separable systems. “Symplectic Neural Networks for learning Generalized Hamiltonians” trains an HNN through an implicit midpoint integrator, uses a symplectic adjoint for sensitivities, and applies backward-error post-processing so that the modified Hamiltonian becomes a more accurate approximation of the true Hamiltonian without requiring a more accurate discretization of the flow map [2606.27029]. A plausible implication is that, for HNNs trained from sampled trajectories rather than analytic derivatives, numerical geometry and statistical learning are tightly coupled.

## 5. Major extensions of the HNN framework

The methodological survey of neural Hamiltonian dynamics identifies four overlapping axes of variation—generalized Hamiltonian system, symplectic integration, generalized input form, and extended problem setting—and the post-2019 literature can be read as a sequence of targeted extensions along those axes [2203.00128].

When additional structure of the Hamiltonian is known, several papers hard-code it. “Separable Hamiltonian Neural Networks” assumes additive separability,
\[
H(q,p)=T(q)+V(p),
\]
and introduces observational, learning, and inductive biases to enforce it. Across all tested separable systems, all separable HNNs outperform vanilla HNNs on both Hamiltonian regression and vector-field regression, and the authors select HNN-OI as the best overall accuracy/time trade-off [2309.01069]. “Adaptable Hamiltonian neural networks” instead augments the input with bifurcation or control parameter channels, effectively learning \(H_\theta(q,p;\mu)\). In the Hénon–Heiles family, training on as few as four parameter values allows prediction across essentially the entire interval \(\alpha\in[0,1]\), including the onset of chaos as quantified by maximum Lyapunov exponent, minimum alignment index, and chaotic fraction [2102.13235].

Other work extends HNNs beyond energy learning alone. “Hamiltonian Neural Networks with Automatic Symmetry Detection” augments the model with a Lie algebra framework, learning both a Hamiltonian and infinitesimal generators \(v^{(k)}\) satisfying approximate invariance \(\widehat v^{(k)}(H)\approx 0\). In the pendulum-on-a-cart experiment, the symmetry diagnostic improves from \(3.1478\) for HNN to \(0.0136\) for SymHNN [2301.07928]. “Hamiltonian-based neural networks for systems under nonholonomic constraints” moves beyond unconstrained Hamiltonian mechanics to pseudo-Hamiltonian constrained systems, using three parallel networks to learn the Hamiltonian, the constraints, and the associated multipliers [2412.03018]. “Port-Hamiltonian Neural Networks with Output Error Noise Models” broadens the setting further to driven, dissipative, partially observed systems with noisy outputs by replacing canonical HNN dynamics with port-Hamiltonian structure,
\[
\dot{x}(t)=\bigl[J(x(t)) - R(x(t))\bigr]\frac{\partial H}{\partial x}(x(t)) + G(x(t))u(t),
\]
and identifying the latent state through SUBNET and an output-error objective [2502.14432].

A further branch emphasizes geometric parameterization and training efficiency. “GeoHNNs: Geometric Hamiltonian Neural Networks” parameterizes inverse inertia on the manifold of symmetric positive-definite matrices via the affine-invariant geometry and combines this with a constrained autoencoder for symplectic latent reduction; on a high-dimensional cloth system, the constrained model achieves mean position error \(1.84\times 10^{-1}\) and mean momentum error \(1.05\), compared with \(1.82\) and \(6.26\) for the unconstrained autoencoder [2507.15678]. “Training Hamiltonian neural networks without backpropagation” replaces end-to-end gradient optimization by sampled hidden features and a least-squares solve for the final linear layer, reporting CPU training more than \(100\) times faster than traditional gradient-based HNN optimization and more than four orders of magnitude accuracy in chaotic examples including Hénon–Heiles [2411.17511].

## 6. Applications, limitations, and current status

Applications of HNNs now span both classical benchmarks and domain-specific problems. The original paper demonstrated ideal oscillators, pendula, orbital dynamics, and latent image prediction [1906.01563]. High-dimensional conservative forecasting was studied in oscillator families and coupled bistable chains [2008.04214]. Engineering extensions include noisy input–output system identification for a nonlinear coupled mass-spring-damper system and a real cascaded-tanks benchmark, where the OE-pHNN reports test RMS \(0.28\) on the real system [2502.14432]. A distinct application to rotating machinery uses the learned HNN weights themselves as features for classification on the MaFaulDa dataset, reporting AUC \(0.78\) for binary normal-versus-abnormal classification and \(0.84\) for a six-class problem [2301.02243].

The standard limitations of HNNs are explicit throughout the literature. Pure HNNs are best suited to conservative mechanical systems with canonical coordinates and access to states or derivatives compatible with Hamilton’s equations [1906.01563][2008.04214]. They do not naturally model dissipation, forcing, friction, contacts, or nonholonomic constraints unless the architecture is altered [1906.01563][2412.03018][2502.14432]. Extrapolation far outside the training region is poor for both HNNs and standard neural networks in the high-dimensional study of Miller et al. [2008.04214]. The adaptable HNN paper further notes that full canonical state data are required and that performance degrades away from the training parameter region [2102.13235].

The empirical and conceptual debate remains active. Strict Hamiltonian assumptions can be mismatched to practical control systems: on MuJoCo environments, the second-order NODE+SO model outperformed HNN-style models, and HNNs underperformed even plain NODEs on all tested environments [2202.04836]. Standard HNNs also do not automatically preserve system symmetries, which motivated the development of symmetry-aware variants [2301.07928]. At the same time, the continued appearance of separable, parameterized, symplectic, constrained, port-Hamiltonian, and geometric HNNs suggests that the central idea remains robust: many dynamical learning problems benefit from representing motion through a scalar generator and then tailoring the surrounding inductive bias to the actual geometry, constraints, and observation model of the target system [2203.00128].

Source: https://www.emergentmind.com/topics/hamiltonian-neural-networks