Module 03 Knowledge Check
5 questions. Pass mark 4 out of 5. Answer every question before checking the answer key below, then retry after reading the feedback.
1. Why must a loss be a single scalar?
- A. To fit in memory
- B. Gradients are defined with respect to a scalar
- C. So it can be printed
- D. Because batches vary in size
2. For y = w * x with x = 3 and w tracked, what is w.grad after y.backward()?
- A. 1.0
- B. 2.0
- C. 3.0
- D. None
3. You call .backward() twice without clearing. What is in .grad?
- A. The most recent gradient
- B. The sum of both gradients
- C. The average of both
- D. None — it was reset automatically
4. After optimizer.zero_grad() in current PyTorch, what is parameter.grad?
- A. A tensor of zeros
- B. None
- C. Unchanged
- D. A tensor of ones
5. You train on data generated by y = 2x0 - 3x1 + 1 and the loss falls steadily. What confirms the loop is correct?
- A. The loss reaching zero
- B. The learned weights approaching [2.0, -3.0] and bias 1.0
- C. Training completing without error
- D. Validation loss falling too
---
Answer Key and Explanations
Check these only after attempting every question.
1. B — Gradients are defined with respect to a scalar
.backward() computes derivatives of one number with respect to the parameters. A loss returning several numbers cannot be backpropagated as-is.
2. C — 3.0
dy/dw = x = 3. Verifying a gradient by hand on a case this small is the fastest way to confirm autograd is doing what you expect.
3. B — The sum of both gradients
Gradients accumulate by design, which supports splitting a large batch. Forgetting to clear means every step uses the sum of all previous ones.
4. B — None
Since 2.0 the default releases the tensor rather than filling it — cheaper. Code reaching for .grad.abs() straight afterwards raises AttributeError. Pass set_to_none=False for the old behaviour.
5. B — The learned weights approaching [2.0, -3.0] and bias 1.0
A falling loss happens for buggy loops too. Recovering the known parameters is a much stronger check.
Practical Check
Apply this module to your own work: complete the module activity for *Autograd, Loss, Backpropagation, and Training Loops*, then write one sentence naming what your result shows and one naming what it does not.
Strong Answer Pattern
A strong answer names the task, the evidence used, the check performed, and the remaining limitation. It avoids "proved", "guaranteed", or "always" unless the evidence genuinely supports it.
