We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
nn.Module Mechanics
PyTorchDefine modules with parameters, buffers and child modules. Save and restore state, switch training modes, and reason about shared weights.
7 exercises
Explore freely. Sign in to keep your progress.
Your learning sequence
- 1 Not solved yet. Register a sequence of model layers Practice · Medium
- 2 Not solved yet. Compare dropout in training and evaluation modes Practice · Easy
- 3 Not solved yet. What the optimiser updates Practice · Medium
- 4 Not solved yet. Share one weight parameter between two layers Practice · Medium
- 5 Not solved yet. Report missing and unexpected checkpoint keys Practice · Medium
- 6 Not solved yet. Read the middle of a model Practice · Medium
- 7 Not solved yet. Initialise the whole tree Practice · Medium
Check yourself
4 questions · not saved while you're signed outUse these questions to check your understanding and compare explanations. Your score does not affect track completion.
With the default settings shown here, which BatchNorm values are registered parameters?
Choose one answer to reveal the explanations. Answers are kept only while this page is open.
from torch import nn
m = nn.BatchNorm1d(3)
print("parameters:", [name for name, _ in m.named_parameters()])
print("buffers:", [name for name, _ in m.named_buffers()])