GSoC '25 Project: Implement a Wishlist Model - Hamiltonian Neural Network

Hello DeepChem Community

I’m Abhay, recent graduate student ( branch-IT ) from Mumbai, India. I am happy to share that I will be working on Implementing Hamiltonian Neural Network (HNN) for my GSoc 25 project.

Throughout the summer, I’ll share weekly updates on the project’s progress and would love to get feedback or suggestions from the community.

Regards,
Abhay Shinde

Week 1 :-

  • This week started with understanding the basic maths which is included in the research paper, to get an basic understanding of how things works behind the scenes ( hamiltonian mechanics ), so started doing numericals on paper. [ Link to pdf ]

  • Then implemented the same maths with pytorch ( for gradients ). [ notebook link ]

  • The author of paper has provided python scripts to generate synthetic data for each experiments mentioned in paper (scritps), so tried to understand by passing some demo data. [ notebook link ]

  • Also at the first page of paper itself, author compared a simple MLP/NN with HNN to see how HNN outperforms vanilla neural networks to conserve the physical systems, so created a colab notebook which compares this two in brief on mass-spring experiment. [ notebook link ]

Slides deck -> Link

Week 2 :-

  • Worked on base HNN class which includes methods/functions to created MLP, forward method, calculating loss, hamiltonian function. [ Link ]

  • Tested this class on experiments mentioned in the paper ( got good results )
    Mass Spring experiment -> [ Link ]
    Pendulum experiment -> [ Link ]

Week 3 :-

  • Created a wrapper for base class which follows the deepchem TorchModel functionality [ Link ] , also added docstrings and type annotations
  • Tested wrapper for experiments :- [experiment1], [experiment2]
  • Created a draft PR for review on the base layer and wrapper class [PR link]

Week 4 :-

  • Minor changes in hnn file:- override predict_on_batch in wrapper, rearrange methods in both base layer and wrapper, added docstrings.
  • Tested new hnn file on experiment and also TorchModel methods such as .fit and .predict.
  • Created PR for base hnn layer and also added test cases file, made changes in docs [ PR link ]

Week 5 :-

  • Updated doc-strings, rearrange structure of test_hnn file ( separate hnn object in each method )

  • Fixed failed CI’s on PR and also PR got merged this week [ LINK ]

  • Implemented different scripts to visualize the results from trained model such as Phase space trajectory, Error Heatmap, comparison of true and predicted (q, p) values, vector field of HNN trajectory [ LINK ]

Week 6 :-

  • Created new PR for deepchem HNN model, added test cases such as overfit, restore and forward also made required changes in docs [ PR link ]
  • Restructured the HNN base class forward function, as now it supports .predict and .evaluate methods too.
  • Minor improvements on docstrings ( added symplectic gradients equations ) and usage examples after review.