SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1906.01563 · 2019

Hamiltonian Neural Networks

arXiv · PDF · Open in the Atlas

Code that ran

4 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 3 failures of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/1906.01563.json · badge: /api/ran/1906.01563.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
greydanus/hamiltonian-nn canonical (classifier label)
classifier basis: classifier_2025
1 ran · 1 no recorded run
MilesCranmer/lagrangian_nns extension (classifier label)
classifier basis: classifier_2025
3 ran · 0 no recorded run
eikehmueller/mlconservation_code reimplementation (classifier label)
classifier basis: classifier_2025
0 ran · 2 no recorded run
FunctionStatusWhere it lives
HNN Ran
ran on a synthesized input · constructed an object; no result was computed
greydanus/hamiltonian-nn/hnn.py
code served (permissive licence) · get_code("bfb9452ce6fe3c52")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, HNN: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a simple differentiable model that outputs [batch_size, 2]
class SimpleModel(nn.Module):
    def __init__(self, input_dim):
        super(SimpleModel, self).__init__()
        self.fc1 = nn.Linear(input_dim, 8)
        self.fc2 = nn.Linear(8, 2)
    
    def forward(self, x):
        x = torch.relu(self.fc1(x))
        x = self.fc2(x)
        return x

input_dim = 4
differentiable_model = SimpleModel(input_dim)

ARGS = {
    'input_dim': input_dim,
    'differentiable_model': differentiable_model,
    'field_type': 'solenoidal',
    'baseline': False,
    'assume_canonical_coords': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type HNN — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a HNN output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
lagrangian_eom Ran
ran; our contract draft was wrong, not the code
MilesCranmer/lagrangian_nns/lnn/core.py
code served (permissive licence) · get_code("88a9847a8a323147")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned ArrayImpl, ndim 1, dtype family float, shape (8,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import jax
import jax.numpy as jnp

def lagrangian(q, q_t):
    """Simple harmonic oscillator Lagrangian: L = T - V = 0.5*q_t^2 - 0.5*q^2"""
    kinetic = 0.5 * jnp.sum(q_t**2)
    potential = 0.5 * jnp.sum(q**2)
    return kinetic - potential

# Create a state vector: [q, q_t] concatenated
# q has 4 dimensions, q_t has 4 dimensions
q = jnp.array([0.1, 0.2, 0.3, 0.4])
q_t = jnp.array([0.5, 0.6, 0.7, 0.8])
state = jnp.concatenate([q, q_t])

ARGS = {
    "lagrangian": lagrangian,
    "state": state,
    "t": None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 1, dtype family float, shape (8,) — shape (8,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
raw_lagrangian_eom Ran
ran; our contract draft was wrong, not the code
MilesCranmer/lagrangian_nns/lnn/core.py
code served (permissive licence) · get_code("f367bad0bdf8c16d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned ArrayImpl, ndim 1, dtype family float, shape (8,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import jax
import jax.numpy as jnp

def lagrangian(q, q_t):
    """Simple quadratic Lagrangian: L = 0.5 * q_t^T @ q_t - 0.5 * q^T @ q"""
    kinetic = 0.5 * jnp.sum(q_t ** 2)
    potential = 0.5 * jnp.sum(q ** 2)
    return kinetic - potential

# Create state vector: [q, q_t] where q has 4 dimensions
q = jnp.array([0.5, 1.0, 1.5, 2.0])
q_t = jnp.array([0.1, 0.2, 0.3, 0.4])
state = jnp.concatenate([q, q_t])

ARGS = {
    "lagrangian": lagrangian,
    "state": state,
    "t": None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 1, dtype family float, shape (8,) — shape (8,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
unconstrained_eom Ran
ran; our contract draft was wrong, not the code
MilesCranmer/lagrangian_nns/lnn/core.py
code served (permissive licence) · get_code("3f8b9827bda70ac8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned ArrayImpl, ndim 2, dtype family float, shape (2, 8) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import jax.numpy as jnp
import jax

class SimpleModel:
    """Minimal model that accepts q and q_t and returns their concatenation."""
    def __call__(self, q, q_t):
        return jnp.concatenate([q, q_t], axis=-1)

# Create model instance
model = SimpleModel()

# Create state: split into q and q_t
# state should be concatenation of q and q_t
# q shape: (2, 4) - batch size 2, dimension 4
# q_t shape: (2, 4) - batch size 2, dimension 4
q = jnp.ones((2, 4))
q_t = jnp.ones((2, 4))
state = jnp.concatenate([q, q_t], axis=0)  # shape (4, 4)

# t parameter is optional (default None)
t = None

ARGS = {
    "model": model,
    "state": state,
    "t": t
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
jax — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, ndim 2, dtype family float, shape (2, 8) — shape (2, 8) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
LagrangianDynamicalSystem Not yet run
unverified (harvested, no recorded run)
eikehmueller/mlconservation_code/src/conservative_nn/nn_lagrangian_model.py
pointer only (licence: GPL-3.0) · get_code("2d9524e322df3463")
How it ran

The body of this sample is withheld: GPL-3.0, as GitHub detects it on this paper's repository, eikehmueller/mlconservation_code, is not in the permissive set Syntology serves inline. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

NNLagrangianModel Not yet run
unverified (harvested, no recorded run)
eikehmueller/mlconservation_code/src/conservative_nn/nn_lagrangian_model.py
pointer only (licence: GPL-3.0) · get_code("a4bfe3de6390ef4b")
How it ran

The body of this sample is withheld: GPL-3.0, as GitHub detects it on this paper's repository, eikehmueller/mlconservation_code, is not in the permissive set Syntology serves inline. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

rk4 Not yet run
unverified (harvested, no recorded run)
greydanus/hamiltonian-nn/hnn.py
code served (permissive licence) · get_code("17a5fed7d8573e71")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 3 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 3 later) and 4 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
lagrangian_eom
brick of this paper's assembly: entry
2 other papers
2 later
1907.04490 (2019-07)
Deep Lagrangian Networks: Using Physics as Model Prior for Deep Learning
2003.04630 (2020-03)
Lagrangian Neural Networks
raw_lagrangian_eom 2 other papers
2 later
1907.04490 (2019-07)
Deep Lagrangian Networks: Using Physics as Model Prior for Deep Learning
2003.04630 (2020-03)
Lagrangian Neural Networks
unconstrained_eom 2 other papers
2 later
1907.04490 (2019-07)
Deep Lagrangian Networks: Using Physics as Model Prior for Deep Learning
2003.04630 (2020-03)
Lagrangian Neural Networks

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Even though neural networks enjoy widespread use, they still struggle to learn the basic laws of physics. How might we endow them with better inductive biases? In this paper, we draw inspiration from Hamiltonian mechanics to train models that learn and respect exact conservation laws in an unsupervised manner. We evaluate our models on problems where conservation of energy is important, including the two-body problem and pixel observations of a pendulum. Our model trains faster and generalizes better than a regular neural network. An interesting side effect is that our model is perfectly reversible in time.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("1906.01563")
get_code_for_paper("1906.01563")
have("1906.01563")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/1906.01563.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/1906.01563.svg)](https://syntology.ai/paper/1906.01563)

Connect an agent — have() is free.