Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a deep learning model in Keras to find CG potential #216

Open
hgandhi2411 opened this issue Jul 20, 2020 · 7 comments
Open

Implement a deep learning model in Keras to find CG potential #216

hgandhi2411 opened this issue Jul 20, 2020 · 7 comments
Assignees
Milestone

Comments

@hgandhi2411
Copy link
Collaborator

No description provided.

@hgandhi2411 hgandhi2411 added this to the v1.1 milestone Jul 20, 2020
@hgandhi2411 hgandhi2411 self-assigned this Jul 20, 2020
@whitead whitead modified the milestones: v1.1, v2.0 Jul 20, 2020
@whitead
Copy link
Collaborator

whitead commented Jul 20, 2020

Let's wait for TF 2.0 port for this one, as that will make it much easier. You could start though with creating layers

@hgandhi2411 hgandhi2411 changed the title Implement CGNets as a Keras model Implement a deep learning model in Keras to find CG potential Jan 4, 2021
@RainierBarrett
Copy link
Collaborator

RainierBarrett commented Mar 2, 2021

Hi all. I'm working on a first pass at something like this, though it's not a deep network yet (but could become one). I'm posting a "working" example in the attached zip. I have a few different energy layers that are based on the TrainableLJ layer from the Force Matching Notebook, including LJ, bonds, angles and dihedrals. For the first pass I'm naively trying to directly fit the coefficients of these for the CG particles in a polymer system. For simplicity it's only using the LJ energy layer right now, but feel free to uncomment the others as you like.

The issue I'm having is that regardless of which layer or combo of layers I run, I always get

IndexError: list index out of range

when running the simulation. Some googling turned up that this can be an issue with the input dimensions for the TF model, but I thought the inputs were determined by HOOMD-TF, so I'm not sure what's wrong with them. Would love another pair of eyes or two to help out on this one.

To reproduce the error:

  1. clone this repo and cd into it
  2. activate a conda environment with HOOMD-TF set up
  3. run conda update -f environment.yaml on the env file from uli-init
  4. pip install -e . in uli-init
  5. unzip this archive
  6. from whatever dir you put those files in, python HTF_CG_MWE.py

@whitead
Copy link
Collaborator

whitead commented Mar 2, 2021

Hey @RainierBarrett. What version of tensorflow were you using?

@RainierBarrett
Copy link
Collaborator

I also forgot to include the .py file! I'll attach here.
TF Version: 2.4.0
HOOMD-blue version: 2.9.3
HTF_CG_MWE.py.txt

@whitead
Copy link
Collaborator

whitead commented Mar 2, 2021

I'm guessing this is related to #285 which was merged in a few hours ago? Try updating to latest or downgrading TF to 2.3.2.

@RainierBarrett
Copy link
Collaborator

Great, that pull fixed the issue. Now I just have to make my dimensions match with the CG energies for training. I'll keep you posted.

@RainierBarrett
Copy link
Collaborator

Good news! I have a working CG model example which can be found in the script here. If you want to run it, the required files '1-length-4-peek-para-only.gsd' and '100-length-4-peek-para-only-production.gsd' can be generated with the following code (make sure to clone from my branch/fork):

import uli_init.simulate as simulate
import hoomd

system = simulate.System(molecule='PEEK', para_weight=1.0,
                         density=0.8, n_compounds=[100],
                         polymer_lengths=[4], forcefield='gaff',
                         assert_dihedrals=True, remove_hydrogens=True)

sim = simulate.Simulation(system, gsd_write=1000, mode='gpu', dt=0.0001)
sim.quench(kT=1., n_steps=1e4, shrink_steps=1e4)

... with n_compounds set to 1 and 100, respectively, and renaming the resulting 'sim_traj.gsd' files accordingly. I'll also attach them for convenience.

The specific system used in my example doesn't really matter as much for this issue, and the uli-init code is only a wrapper for setting up polymer sims quickly. The relevant model-building code starts on line 131

I've been running this code from a docker container but this may not run on all machines. I had to compile TF from source and this image was compiled only for specific CUDA compute-capable devices (6.0 & 7.0).

All this to say, this should provide a scaffold to put together an example notebook with, if you guys want to slot this into your workflow instead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants