A linear layer transforms an input vector using a learnable weight matrix and bias vector: xWᵀ + b. Also called a fully connected or dense layer, it connects every output neuron to every input neuron. In a drug-discovery model, such layers can turn a molecular representation into features used to predict a molecule’s properties. section 8.2.1 section 8.2.2
In PyTorch, nn.Linear(input_size, 512) maps input_size features to 512 outputs. Its weight matrix has shape (512, input_size), and its bias has 512 values. The output size of one layer must match the input size of the next. Weights and biases are learned during training. section 8.2.2
Predicting kinase binding
A feedforward network takes a molecular bit vector, with 2048 features by default, through linear layers sized 2048 → 512 → 256 → 1. ReLU follows each hidden linear layer to introduce nonlinearity, and dropout provides regularization. The final layer produces a single prediction. section 8.2.2
Listing 8.6 Kinase Binder Neural Network Architecture
class KinaseBinderNN(nn.Module):
def __init__(self, input_size=2048):
super(KinaseBinderNN, self).__init__()
self.fc1 = nn.Linear(input_size, 512)
self.fc2 = nn.Linear(512, 256)
self.fc3 = nn.Linear(256, 1)
self.relu = nn.ReLU()
self.dropout = nn.Dropout(0.2)
def forward(self, x):
x = self.dropout(self.relu(self.fc1(x)))
x = self.dropout(self.relu(self.fc2(x)))
x = self.fc3(x)
return x
Inspect the layer definitions and forward pass, including where ReLU and dropout are applied. section 8.2.2
Predicting drug-target affinity
After graph pooling, two linear layers transform a 312-dimensional molecular representation through 1024 dimensions into a 128-dimensional embedding. A separate protein embedding is combined with it; further linear layers then map the combined 256 features through 1024 and 512 dimensions to one unbounded affinity prediction. section 11.5.2 section 11.5.3
Layer width is a design trade-off: more neurons can increase learning capacity, but also increase computational cost and the risk of overfitting. section 8.2.1
















