Training & tuning
Train a DTI model by pairing a drug and a protein encoder, tune train_epoch, LR, batch_size and cls_hidden_dims, then save the checkpoint with its config.
DeepPurpose supports 50+ neural architecture combinations from 15+ compound encoders and 7+ protein encoders. This guide covers training DTI prediction models.
Basic training loop
Architecture options
DeepPurpose uses a modular architecture where drug and target encoders are combined with a classifier head:
Common encoder combinations:
- Morgan + AAC: Fast baseline, good for small datasets
- CNN + CNN: Balanced performance and speed
- Transformer + Transformer: Best for large datasets
- MPNN + CNN: Graph-based drug representation with sequence-based protein encoding
Hyperparameter tips
Key hyperparameters to tune:
| Parameter | Default | Description |
|---|---|---|
train_epoch | 100 | Number of training epochs |
LR | 0.001 | Learning rate |
batch_size | 256 | Training batch size |
cls_hidden_dims | [1024, 1024, 512] | Classifier MLP hidden layer sizes |
cnn_drug_filters | [32, 64, 96] | CNN filter sizes for drug encoder |
cnn_target_filters | [32, 64, 96] | CNN filter sizes for target encoder |
transformer_n_layer_drug | 8 | Transformer layers for drug encoder |
transformer_n_layer_target | 8 | Transformer layers for target encoder |
Tuning recommendations:
- Start with small epochs (10-20) and increase after verifying loss trends.
- Use
batch_sizeto fill GPU memory without OOM; scaleLRwith batch size cautiously. - For small datasets (<1000 samples), use simpler encoders (Morgan, AAC) and smaller hidden dims.
- For GNN encoders (MPNN, DGL_*), reduce batch size as they are more memory-intensive.
Validation and metrics
DeepPurpose automatically evaluates on validation data during training:
The training process logs:
- Training and validation loss per epoch
- MSE, Pearson correlation, Concordance Index (CI) for regression
- AUROC, AUPRC for classification tasks
Checkpoints
- Save
model.pt, encoder configs, and the command/args used. - Keep the tokenizer/featurizer versions with the checkpoint for reproducibility.
Resource guidance
- CPU-only runs: lower batch size (e.g., 64) and fewer workers.
- GPU runs: ensure CUDA toolkit matches torch; set
TORCH_CUDA_ARCH_LISTif building from source.
Multi-task and virtual screening
DeepPurpose also supports:
Was this page helpful?
Serving & deployment
Export a trained DeepPurpose model to TorchScript or ONNX, stream a chunked CSV through batch prediction, or wrap it in a FastAPI predict endpoint.
Troubleshooting DeepPurpose
Fix DeepPurpose installs, DGL and RDKit imports, CUDA device errors, out-of-memory training runs, SMILES parsing failures and diverging loss or NaNs.