Skip to content
/ PotFit Public

A PyTorch Example of Potential Fitting

License

Notifications You must be signed in to change notification settings

Tony-Y/PotFit

Repository files navigation

PotFit

A PyTorch Example of Potential Fitting

Problem

Provide there exists a potential V(x). Given some observations { V(xi), dV/dx(xi) }i=1,...,N, obtain the approximate potential P(x) which satisfies L(V,P) < δ, where

L(V,P) = (1/N) ∑i ( |V(xi)-P(xi)|2 + λ |dV/dx(xi)-dP/dx(xi)|2 ).

δ > 0 and λ > 0, and they are given constants.

Potentail

The values at N=100 random points are shown as solid cricles.

Models

This code uses the neural networks as follows:

z0 = σ( x Win ),

zl = σ( zl-1 Wl )   (l=1,...,L),

P(x) = zL Wout + bout,

where σ(x) = SSP(x) = Softplus(x) - Softplus(0). Win, Wl, and Wout are the 1xH, HxH, and Hx1 matrices, respectively.

The default setting: L=5 and H=500.

Enviroment

  • Python 3.7
  • PyTorch 1.0.0.dev20181107

How to run

python potfit.py --num_epochs 20000

This code uses λ = 1/25.

You will eventually get outputs like as follows:

epoch 19995 lr 0.0003774 mse0 0.00228 mse1 2.07881 loss 0.08543
epoch 19996 lr 0.0003774 mse0 0.00557 mse1 2.85378 loss 0.11972
epoch 19997 lr 0.0003774 mse0 0.00285 mse1 4.02198 loss 0.16373
epoch 19998 lr 0.0003774 mse0 0.00476 mse1 4.44875 loss 0.18271
epoch 19999 lr 0.0003774 mse0 0.01051 mse1 2.68157 loss 0.11777
Best score: 0.007930990790831857

loss = mse0 + λ mse1.

You can plot predictions of the best model as the following:

python plot_predictions.py best

Predicted Potentail

Potential History

References

Deep Neural Networks

Shiyu Liang and R. Srikant, "Why Deep Neural Networks for Function Approximation?", ICLR 2017 link

Softplus

Vinod Nair and Geoffrey E. Hinton, "Rectified Linear Units Improve Restricted Boltzmann Machines", ICML 2010 link

Shifted Softplus (SSP)

Kristof T. Schütt, Huziel E. Sauceda, Pieter-Jan Kindermans, Alexandre Tkatchenko, and Klaus-Robert Müller, "SchNet - a deep learning architecture for molecules and materials", J. Chem. Phys. 148, 241722 (2018) link

License

Apache License 2.0

Releases

No releases published

Packages

No packages published

Languages