Difficulty training to simple (Lennard-Jones) model

Issue #75 resolved
Andrew Doyle created an issue

I've been having some issues getting AMP to converge, as it seems eventually more and more training has no discernible impact on RMSE.

To make things as simple as I could imagine, I've created an artificial system of two hydrogen atoms bound by a Lennard-Jones potential (with energy values input by hand). Unfortunately, it still seems to struggle a fair amount, even with what I'd imagine is an incredibly overfit neural network.

I've attached a PDF outlining the procedure I used, a few figures I think help understand the results, and the script I used. I've also attached the ASE atoms object.

Looking at a few other issues here, it seems to me that this could be related to gradient evaluation.

Is there something else I should try?

PS - Thanks for all the awesome work. I'm super excited to get to play around with this. :) PPS - The version of AMP here may be a bit dated (as you can see in the import statements). As far as I am aware, this is the last update before force training was added, and this model does not use any forces.

Comments (8)

  1. Alireza Khorshidi

    Thanks Andrew for the feedback! In your script, I am seeing that you have used tfAmpNN for modeling. I personally, have no yet find the chance to work with it.

    Have you ever tried version v0.4.1? I would expect that it should quite easily train to this simple system, not only to energies but also to forces. I would be happy to hear your experience.

  2. Andrew Doyle reporter

    I am using tfAmpNN (because I work with Zach Ulissi), and the last time I tried to work with AMP other methods used a pretty extreme amount of memory. What other scheme(s) are currently operational?

    I'm currently trying to move to v0.4.1 , but I'm having some issues with setting it up (because I'm not great with software installation). I'll let you know if I get a chance to try it.

  3. Alireza Khorshidi

    The development version should also be ready (I just added fortran modules to it today). That should take less memory. Though may be not very stable at the moment.

    Great! Sure! Let me know if you faced any issue with installation.

  4. Jacob Boes

    I've just run the example on v0.4 and it seems to be working.

    I'd be interested in knowing if this error is related to

    @aldoyle Thank you for the tfAmpNN example code. I'd be interested in knowing when you believe it is stable enough for general use.

  5. Andrew Doyle reporter

    I've attached an image comparing v0.4 (as suggested by Alireza and with a script similar to the one provided by Jacob - mostly changing "Behler" to "Gaussian") to v0.5 / TensorFlow. Because v0.5 is in flux, it's hard for me to know how this would compare to a current (fresh) installation, though I could do that if it would be worthwhile. It would just involve updating how a few packages are stored on our end.

    Simply put it seems that some combination of the change to version 0.5 and using tensorflow makes training far harder. Even with a substantially larger neural network and substantially more training epochs, I'm unable to get below 0.01 eV RMSE/atom as done relatively easily in v0.4

    version_comparison.png

  6. andrew_peterson repo owner

    I just re-ran the example in v0.5 and it works fine. Updated script is

    from amp import Amp
    from amp.descriptor.gaussian import Gaussian
    from amp.model.neuralnetwork import NeuralNetwork
    from amp.model import LossFunction
    from ase.io import read
    import matplotlib.pyplot as plt
    
    images = read('atoms.traj', ':')
    
    d, E = [], []
    for atoms in images:
        E += [atoms.get_potential_energy()]
        d += [atoms.get_distance(0, 1)]
    
    plt.figure(figsize=(6, 4))
    plt.plot(d, E, 'bo-', label='Specfied energy')
    
    calc = Amp(descriptor=Gaussian(),
               model=NeuralNetwork())
    calc.model.lossfunction = LossFunction(
        convergence={'energy_rmse': 0.0001,
                     'force_rmse': None},
        force_coefficient=0.)
    
    calc.train(images,
               train_forces=False)
    
    
    nnE = []
    for atoms in images:
        atoms.set_calculator(calc)
        nnE += [atoms.get_potential_energy()]
    
    plt.plot(d, nnE, 'ro', label='NN prediction')
    plt.legend(loc='best')
    plt.tight_layout()
    plt.savefig('lj-temp.png')
    

    Presumably, this also converges in tensorflow, but I can't successfully turn off force training in tensorflow. (And these atoms have no forces.) I'll close the issue.

  7. Andrew Doyle reporter

    My apologies - this was resolved some time ago.

    There were some issues with the tensorflow portion of the code at the time of this posting. I believe we've largely worked through them now, though I'm not sure which versions exist in various places on the net.

  8. Log in to comment