Bachelor's Thesis:
RF-HNNs-Thesis.pdf
Bachelor's Thesis Presentation:
RF-HNNs-Presentation.pdf
This repository is based on the implementation from:
Training Hamiltonian Neural Networks without Backpropagation
- Repository: https://github.com/AlphaGergedan/Sampling-HNNs
- Paper: https://arxiv.org/abs/2411.17511
The following models are available:
-
MLP: ODE-Net, directly approximates
q_dotandp_dot. paper -
HNN: Hamiltonian neural network approximates
H, then recoversq_dotandp_dotusing automatic differentiation and Hamilton’s equations. paper
All models are available in sampled form (S-MLP, S-HNN).
In sampled models, hidden-layer parameters are randomly sampled and the final layer is computed
using a least-squares solution.
Different sampling strategies are available through the SWIM method.
paper
This project depends on the submodule swimnetworks:
git submodule init
git submodule updateto clone the submodule.
Create the conda environment:
conda env create --file=environments.ymlThen activate it with conda activate s-hnn.
After setting up the conda environment, you can use the bash script main located at the root of the
project.
- Run
./main --helpfor usage. - Training a traditional network:
./main --target single_pendulum --model {MLP,HNN} - Sampling a network:
./main --target single_pendulum --model {S-MLP,S-HNN}
Here is an example to quickly train a Sampled-HNN for single pendulum:
python src/main.py --target single_pendulum --model S-HNNFirst-order error correction example:
python src/main_limited_data.py --target single_pendulum --model S-HNNFor details you can refer to the original paper.
This repository extends the original Sampled-HNN framework to gravitational N-body systems.
Main additions:
- 2-body orbit generation :
src/data/two_body_orbit_generator.py - 3-body orbit generation :
src/data/three_body_orbit_generator.py - Hamiltonian formulation of the 2-body system :
src/hamiltonian/two_body.py - Hamiltonian formulation of the 3-body system :
src/hamiltonian/three_body.py - Symplectic integrators :
src/integrators/ - Training and evaluation notebooks for 2-body and 3-body systems :
analyze_two_body.ipynb&analyze_three_body.ipynb - Generated plots for the thesis
plots/
