Sequential is a PyTorch container for feed-forward models: provide submodules in order, then pass each module’s output to the next. It turns a network definition into a readable chain that can be trained and used for inference like any other model. section 2.2.2
Two-layer fully connected network
model = nn.Sequential(\n nn.Linear(1, 10),\n nn.Linear(10, 1),\n)\n\nThe first layer maps one input feature to ten hidden units; the second maps those units to one output. The same model can be passed to the existing training and inference code. section 2.2.2
Use Sequential when the computation is naturally a simple ordered pipeline:
- Stack linear layers and nonlinearities to build fully connected networks. section 2.7
- Combine preprocessing, convolution, normalization, and activation modules inside a larger component. section 6.5.2
- Reuse a module object inside the sequence when layers need shared weights. section 4.1.1
Figure 2.6 Converting the conceptual feed-forward fully connected network into a PyTorch Module. nn.Sequential is a wrapper that takes two nn.Linear layers. The first nn.Linear defines the mapping from input to hidden layer, and the second nn.Linear defines the mapping from hidden layerto output.
Shows how Sequential wraps two linear layers, connecting the input to a hidden layer and then to the output. section 2.2.2

