Module 02 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. A prediction has shape (n, 1) and a target has shape (n,). What does MSELoss do?
- A. Raises a shape error
- B. Broadcasts to (n, n) and returns a number computed on nonsense
- C. Silently reshapes the target
- D. Returns n separate losses
2. torch.from_numpy(arr) versus torch.tensor(arr) — what is the difference?
- A. No difference
- B. from_numpy shares memory with the array; tensor copies it
- C. tensor is faster
- D. from_numpy always produces float32
3. A dataset of 20 items with batch_size=6 produces how many batches, and of what sizes?
- A. 3 batches of 6, discarding 2
- B. 4 batches: 6, 6, 6, 2
- C. 4 batches of 5
- D. 20 batches of 1
4. Why should validation data not be shuffled?
- A. Shuffling is slower
- B. So per-batch metrics stay comparable between runs
- C. Shuffling changes the model
- D. It would leak data
5. Why must scaling statistics come from the training split only?
- A. It is faster
- B. Otherwise validation data influences the training transformation and inflates the score
- C. The test set has a different distribution
- D. Standard deviation is undefined otherwise
---
Answer Key and Explanations
Check these only after attempting every question.
1. B — Broadcasts to (n, n) and returns a number computed on nonsense
Broadcasting aligns from the right and produces an (n, n) matrix of pairwise differences. It runs, returns a number, and trains on something meaningless.
2. B — from_numpy shares memory with the array; tensor copies it
Mutating the array afterwards changes a tensor created with from_numpy. That produces a bug far from its cause.
3. B — 4 batches: 6, 6, 6, 2
The final batch is partial. Code assuming a fixed batch size breaks there; drop_last=True discards it at the cost of real data.
4. B — So per-batch metrics stay comparable between runs
Shuffling validation makes batch-level metrics jump between epochs for reasons that have nothing to do with the model.
5. B — Otherwise validation data influences the training transformation and inflates the score
Computing the mean over the whole frame is a leak. The improvement it produces is fictional and cannot be measured.
Practical Check
Apply this module to your own work: complete the module activity for *Tensors, Shapes, Datasets, and DataLoaders*, 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.
