torch.nn.Module is PyTorch’s base class for neural-network components. A custom model subclasses it, defines its layers in __init__, and defines computation in forward. Assigning layers such as Linear modules to the class makes the network’s architecture and trainable parameters part of one reusable object. section 8.2.2
Build a custom module around three practical ideas:
- Initialize the parent module with super().__init__() before defining the network’s layers. section 8.2.2
- Declare layers such as nn.Linear(input_size, 512), matching each layer’s output size to the next layer’s input size. section 8.2.2
- Implement forward to apply transformations in order, including nonlinear activation and dropout before returning the prediction. section 8.2.2
Kinase activity prediction
A molecule represented by a fingerprint vector can enter a module with three fully connected layers: 2048 input features become 512, then 256, then one output. ReLU supplies nonlinear transformations, while dropout with rate 0.2 is applied after the first two hidden layers.






