Skip to course content
Free PyTorch course

Advanced Deep Learning with PyTorch

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?

2. torch.from_numpy(arr) versus torch.tensor(arr) — what is the difference?

3. A dataset of 20 items with batch_size=6 produces how many batches, and of what sizes?

4. Why should validation data not be shuffled?

5. Why must scaling statistics come from the training split only?

---

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.