Skip to content
← All tracks

nn.Module Mechanics

PyTorch

What a Module actually is: a registry of parameters, buffers and children with hooks on the edges. Parameters versus buffers, `state_dict` round-trips, what `train()` really changes, and weight sharing that survives a save.

0 / 7 solved
  1. 1. Not solved yet. The layers the optimiser never saw
  2. 2. Not solved yet. Two modes, one flag
  3. 3. Not solved yet. What the optimiser updates
  4. 4. Not solved yet. One matrix in two places
  5. 5. Not solved yet. The weights that did not load
  6. 6. Not solved yet. Read the middle of a model
  7. 7. Not solved yet. Initialise the whole tree

Check yourself

4 questions · one attempt each

These do not count toward finishing the track. They are here to catch the things that are easy to read past.

0 / 4

A BatchNorm1d holds weight, bias, running_mean, running_var and num_batches_tracked. Which are parameters?

m = nn.BatchNorm1d(3)
[n for n, _ in m.named_parameters()]
[n for n, _ in m.named_buffers()]
Question 1 of 4