How calvin-zcx/moflow works
Project Type & Purpose
• MoFlow is a deep learning project focused on the generative modeling of molecular graphs using invertible flow architectures.
• The project involves data preprocessing (for handling molecular datasets like QM9 and ZINC250K), model training using specialized invertible flow techniques (including coupling layers and Glow variants), generation via reconstruction, random sampling, and interpolation, and finally property optimization (e.g., QED and plogp optimization).
File Structure
• At the top level, you see configuration files (.idea, License.md, README.md) and two main directories:
• The "data" directory contains Python modules for:
▪ Data loading (data_loader.py)
▪ Preprocessing (data_preprocess.py)
▪ Parsing and transforming datasets (data_frame_parser.py, transform_qm9.py, transform_zinc250k.py)
▪ Converting SMILES to graphs (smile_to_graph.py)
▪ Relevant data files (CSV and JSON files).
• The "mflow" directory contains the core modeling code:
▪ "models" subdirectory defines various neural network model components (basic, coupling, glow, hyperparams, and utility functions).
▪ "utils" subdirectory includes supporting modules (environment setup, model utilities, molecular metrics, timing, etc.).
▪ Stand-alone scripts for training (train_model.py), generation (generate.py), and property optimization (optimize_property.py).
▪ A “fig” directory for saving figures from experiments (e.g., interpolation outputs and optimization results).
• This clear separation indicates an architecture that divides pre-processing, model definition/training, and inference/optimization.
README for Additional Insights
• The README explains installation steps, pre-processing commands, training commands (for different datasets), and how to run various experiments (reconstruction, random generation, interpolation, and molecular optimization).
• It provides command-line examples that imply a pipeline where the output from training (model snapshots, hyperparameters) is fed into generation and optimization scripts.
• It outlines details on experimental configuration (e.g., setting batch sizes, temperature, interpolation parameters) that are key to understanding the system's data flow and control paths.
Relationships and Data Flow
– From raw molecular data → Data Preprocessing.
– From Preprocessing → Model Training.
– From Model Training → Generation (for reconstruction, random sampling, and interpolation).
– From Generation → Property Optimization (when optimized output is needed).
• Optionally, include external dependency notes (e.g., PyTorch powering the training, RDKit for chemical informatics).
Architectural Patterns & Design Principles
• Modular design: Each component (data processing, training, inference, optimization) is separate and can be worked on independently.
• Command-line driven pipeline: The README scripts illustrate a clear, linear workflow.
• Reusability and extensibility: The project is built such that new datasets or additional property predictors can be integrated.
• Use appropriate designs such as functional separation (separating model code from utilities) and layered architecture (data, model, inference, optimization).