kfzyqin / Implementation-MolGAN-PyTorch

PyTorch implementation of MolGAN: MolGAN: An implicit generative model for small molecular graphs.
53 stars 9 forks source link


PyTorch Implementation of MolGAN

UsageExhibitionCitationCreditsLicence

Overview

This repository contains a PyTorch implementation of MolGAN: An implicit generative model for small molecular graphs (https://arxiv.org/abs/1805.11973).

Usage

You can either run MolGAN or MolVAE. Please download and preprocess the dataset before training molGAN.

Data Download

Just simply run a bash script. You can find such a bash script in the data directory. If you see warnings or even errors, please just don't worry.

If you wish to use the QM9 dataset, you can skip the data downloading and directly proceed to data preprocessing.

bash download_dataset.sh

Data Preprocessing

Just run the python script below. You will need to comment different different code sections in the main function. It is too easy to figure out how to do.

python sparse_molecular_dataset.py

MolGAN

Simply run the following command to train.

python main_gan.py

MolVAE

For your convenience, a VAE version is also implemented.

python main_vae.py

Testing

You will need to change some arguments in args.py to test the saved model. It is too easy and I believe you can figure out how to do it.

Kind Reminder

If you witness low or even zero validity for generated molecules during training, that is normal. Please just don't worry.

Molecule Generation Exhibition

These results are trained with the QM9 dataset.

Pure RL (WGAN-Lambda = 0.0)

rl_1 rl_2 rl_3 rl_4 rl_5 rl_6

Mixture of RL and GAN (WGAN-Lambda = 0.5)

wla_p5_1 wla_p5_2 wla_p5_3 wla_p5_4 wla_p5_5 wla_p5_6

Pure GAN (WGAN-Lambda = 1.0)

pure_gan_1 pure_gan_2 pure_gan_3 pure_gan_4 pure_gan_5 pure_gan_6

MolVAE Reconstruction

vae_rec_1 vae_rec_2 vae_rec_3 vae_rec_4 vae_rec_5 vae_rec_6

MolVAE Sampling

sample_1 sample_2 sample_3 sample_4 sample_5 sample_6

Dependencies

I use PyTorch 1.5. There is no magic for installing packages. You can just install all the required packages if you run into no-such-package issues :-)

Contacts

If you have any questions regarding this implementation. Please lodge Github issues. You can also contact Zhenyue Qin (zhenyue.qin@anu.edu.au). I aim to respond emails as soon as I see them :-)

Citation

Apart from citing the MolGAN paper, please also consider citing this Github page if you find this implementation assists you :-)

@misc{qin2020molgan_pytorch,
  author = {Qin, Zhenyue},
  title = {MolGAN Pytorch Implementaion},
  year = {2020},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/ZhenyueQin/Implementation-MolGAN-PyTorch}}
}

Credits

This repository uses the following implementations:

Licence

CC-BY-4.0