Building Models with nn.Module
Layers, forward passes, and what nn.Linear does under the hood.
nn.Linear(in_features, out_features) computes the affine transform
y = x @ W.T + b internally, with W and b as learnable parameters. Every
model is a subclass of nn.Module that defines its layers in __init__ and
how data flows through them in forward.
| Layer | Use | Example |
|---|---|---|
| fully-connected (dense) layer |
|
| activation functions |
|
| 2-D convolution | slides a learned kernel over an image tensor |
| randomly zero elements during training (regularization) |
|
| chain layers without writing a class |
|
Now practice it
Exercises that use what this lesson just covered.