A neural network is a model made of interconnected units arranged in layers. It learns patterns from data by adjusting parameters such as weights, rather than following a hand-written checklist of rules. Neural networks underpin deep learning and can capture complex, nonlinear relationships between molecular structure and properties. section 1.2.2 section 8.1.2
For ligand-based screening, a network can predict a compound’s activity against a target protein. In an EGFR example, each molecule is represented by a 2,048-bit Morgan fingerprint, and the network outputs a predicted pIC50 activity value. Mean squared error measures the difference between predictions and measured values; gradients indicate how to adjust the weights to improve predictions. section 8.0 section 8.2
A practical PyTorch workflow connects the model to molecular data:
- Split molecules into training, validation, and test sets. A scaffold split groups molecules by structural scaffold when separating the test set. section 8.1.2
- Convert molecular structures into numerical fingerprints and load them as tensors, along with their activity values. section 8.1.2 section 8.3
- Train the network using a loss function and optimizer, monitor validation performance, and evaluate predictions on the held-out test set. Save the fitted parameters for reuse. section 8.1.2 section 8.3
Listing 8.3 MoleculeDataset Data Loader
def smiles_to_fp(smiles, fp_size=2048):
mol = Chem.MolFromSmiles(smiles)
if mol is None:
return None
mfpgen = rdFingerprintGenerator.GetMorganGenerator(
radius=3, fpSize=fp_size
)
fp = mfpgen.GetFingerprint(mol)
arr = np.zeros((fp_size,), dtype=np.int8)
DataStructs.ConvertToNumpyArray(fp, arr)
return arr
class MoleculeDataset(Dataset):
def __init__(self, smiles, activities):
self.smiles = smiles
self.activities = activities
self.fingerprints = [smiles_to_fp(s) for s in smiles]
def __len__(self):
return len(self.smiles)
def __getitem__(self, idx):
fp = torch.tensor(self.fingerprints[idx], dtype=torch.float32)
activity = torch.tensor([self.activities[idx]], dtype=torch.float32)
return fp, activity
This dataset converts SMILES strings into Morgan fingerprints and returns each fingerprint and activity as PyTorch tensors. section 8.1.2
criterion = nn.MSELoss()
optimizer = optim.Adam(model.parameters(), lr=0.001)
scheduler = ReduceLROnPlateau(
optimizer, mode='min', factor=0.5, patience=5
)
train_model(
model, train_loader, val_loader, criterion, optimizer,
scheduler, device, num_epochs=50
)
This training call uses mean squared error, the Adam optimizer, and a learning-rate scheduler. section 8.1.2
Test performance matters more than how well a model fits its training data: drug discovery often involves molecules unlike those already labeled. Deep neural networks typically need substantial, representative data, and labeled compounds can be expensive to collect. Compare results with appropriate baselines rather than assuming a neural network is best for every task. section 1.2.2 section 6.4.1
A comparison on RNA-binding molecules
For distinguishing RNA-binding from protein-binding small molecules, a reported neural network achieved an average area under the precision-recall curve of 0.78. An XGBClassifier comparison achieved 0.79 under stratified 10-fold cross-validation, illustrating why a tree-based baseline is useful. section 6.4.1










