Skip to content

henribonamy/MolGAN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MolGAN

A PyTorch implementation of the MolGAN paper, used to generate valid molecular structures. The paper uses RL to optimize for certain chemical properties, but this implementation does without RL by monitoring validity and novelty algorithmically.

Generated Molecules

Architecture

This project trains a generative model to create novel, chemically valid molecules represented as graphs. The generator produces adjacency matrices (bonds) and node features (atoms), while a graph convolutional discriminator evaluates their realism.

  • Generator: Multi-layer perceptron with Gumbel-Softmax for discrete graph generation
  • Discriminator: Relational Graph Convolutional Network (R-GCN) with graph pooling
  • Training: WGAN-GP with gradient penalty for (relatively) stable adversarial learning
  • Dataset: QM9 molecular dataset (filtered to C, O, N, F atoms, up to 9 heavy atoms)

Installation

pip install -r requirements.txt

Training

Run the training script:

python src/train.py

This will:

  • Download and prepare the QM9 dataset
  • Train the generator and discriminator for 15 epochs
  • Save the best (for % validity) generator checkpoint as generator_<validity>.pt

Example Training Progress

Sampling Molecules

Generate novel molecules using the trained model (you can use the provided generator.pt or train your own.)

python src/sample_molecules.py

This will:

  • Load the trained generator from generator.pt
  • Generate 20 novel molecules (not in training set)
  • Save images to sampled_molecules/
  • Ensure all molecules are valid, unique, and novel

Original Paper

Based on:

  • De Cao, N., & Kipf, T. (2018). MolGAN: An implicit generative model for small molecular graphs.

About

Replicating the MolGAN paper. WGAN-GP architecture to generate graph-represented molecules.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages