torch.nn.Sequential is a PyTorch container for composing layers in a fixed order. If the layers represent functions f₁, f₂, and f₃, the model computes f₃(f₂(f₁(X))). Each layer receives the previous layer’s output, turning the forward pass into a readable chain. section 8.5 section 10.6.1
A Sequential pipeline can combine:
- Linear layers and sigmoid activations for a regression model. section 8.5
- Convolutional layers and intervening layers for an image-oriented neural network. section 10.6.1
- A custom Module’s forward method can delegate computation to the Sequential object. section 8.5
Two hidden-layer regression network
A model receives three input features, applies Linear(input_size, 10), Sigmoid(), Linear(10, 5), Sigmoid(), and Linear(5, 1), then returns self.model(X). Training calls nn(X) for the forward pass before computing MSE loss and gradients. section 8.5
