Skip to content

MoFlowGAN is a normalizing flow for molecular graphs that is heuristically biased towards easily synthesized, drug-like molecules

License

Notifications You must be signed in to change notification settings

thisisntnathan/MoFlowGAN

Repository files navigation

MoFlowGAN

You've found the working repo for MoFlowGAN, a normalizing flow that can be trained like a GAN to generate high-quality molecular graphs. The code here works, so feel free to train your own model and generate your own molecules. There's even a Google Colab notebook linked below! Take a look at our preprint on ChemRxiv for the nitty gritty details!

Training your own model

Installing dependencies

It's best to run MoFlowGAN in its own conda environment. Learn more about conda and virtual environments here!

conda create --name moflow python pandas matplotlib 
conda activate moflow
conda install pytorch=1.12 torchvision cudatoolkit -c pytorch
conda install rdkit
conda install orderedset
conda install tabulate
conda install networkx
conda install scipy
conda install seaborn
pip install cairosvg
pip install tqdm

Preprocess the data

Right now we've only trained MoFlowGAN on QM9; our plans are to extend to ZINC250.

cd data
python data_preprocess.py --data_name qm9

Alternatively, you can just clone this repository using:

git clone https://github.com/thisisntnathan/MoFlowGAN.git MoFlowGAN

Training

To train MoFlowGAN call reward_trainer.py using the command below making sure to set your desired objective coefficients (adv_reg and rl_reg). There are many more hyperparameters you can play with, a full list of arguments see reward_trainer.py

python reward_trainer.py --data_name qm9 -t 237 --max_epochs 50 --gpu 0 --adv_reg 0.27 --rl_reg 0.42 --debug True --save_epochs 5 --save_dir=./results/ 2>&1 | tee ./results/MoFlowGAN.log

Evaluation

We provide a simple Jupyter notebook evaluate.ipynb for evaluating your model's performance!

Open In Colab

Contribution

If you have any questions, comments, or suggestions feel free to reach out (or submit a PR)!

Citation

Read our preprint on ChemRxiv!

Acknowledgements

MoFlowGAN started off as a final project for Cornell's CS 6784: Advanced Topics in Machine Learning - Deep Learning. We thank Prof. Kilian Weinberger for insights, input, and fruitful discussion.

MoFlowGAN's base layers are structured off those of MoFlow (code) and MolGAN (code)

About

MoFlowGAN is a normalizing flow for molecular graphs that is heuristically biased towards easily synthesized, drug-like molecules

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •