Molecular ML / PyTorch

Molecular learning.
Made accessible.

Predict properties, learn representations, and generate molecules with a familiar Python interface.

pip install torch-molecule
Aspirin / molecular graph
Aspirin represented as a molecular graph, with atoms as nodes and bonds as edges.
SMILES → graph 13 heavy atoms · 13 bonds

31 model classes

Predict. Encode. Generate.

All models

Python API

A familiar interface.
A molecular input.

Start with SMILES. Configure a model, call fit(), and put it to work.

Explicit parameters, CPU and GPU support, and local checkpoints.

Follow the quickstart
from torch_molecule import GNNMolecularPredictor

smiles = ["CCO", "CCCO", "c1ccccc1", "CCOC(C)=O"]
mass = [[46.07], [60.10], [78.11], [88.11]]

model = GNNMolecularPredictor(
    num_task=1, task_type="regression",
    num_layer=2, hidden_size=64, epochs=10,
)
model.fit(smiles, mass)
result = model.predict(["CCCCO"])
print(result["prediction"])
from torch_molecule import AttrMaskMolecularEncoder

smiles = ["CCO", "CCCO", "c1ccccc1", "CCOC(C)=O"]

encoder = AttrMaskMolecularEncoder(
    num_layer=2,
    hidden_size=64,
    epochs=10,
)
encoder.fit(smiles)
embeddings = encoder.encode(smiles)
print(embeddings.shape)
from torch_molecule import DemoDiffMolecularGenerator

smiles = ["CCO", "CCCO", "c1ccccc1", "CCOC(C)=O"]

model = DemoDiffMolecularGenerator(
    num_layer=2, hidden_size=64, num_head=4,
    diffusion_steps=20, epochs=25,
    learning_rate=1e-3,
)
model.fit(smiles)
molecules = model.generate(n_samples=5)
print(molecules)

Featured methods

Explore the methods.

Model collection

Documentation

Build your next experiment.