mirror of
https://github.com/rohitg00/ai-engineering-from-scratch.git
synced 2026-10-02 01:54:39 +08:00
Every "Test Your Understanding" quiz placed the correct answer in option B.
Across the 2026 questions in 338 quiz files the correct answer sat at index 1
in 61.5% of cases (uniform would be ~25%), and 107 files had every answer at B,
making the quizzes guessable without reading them.
scripts/debias_quizzes.py rewrites each question's option order with a
deterministic, content-seeded permutation and updates the correct index to
follow the moved answer. It is idempotent: options are canonicalised to a sorted
base before permuting, so re-running produces byte-identical output. Questions
whose options reference each other by position ("all of the above", "both A and
B") are left untouched. The correct-answer value, the option set, and every
explanation are preserved exactly; only order and the index change.
Result: A 23.8% / B 26.3% / C 23.5% / D 26.4%.
The script doubles as a CI guard: `--check` exits non-zero if any quiz is not
de-biased, wired into the curriculum workflow so new lessons cannot regress.
Fixes #368
38 lines
2.8 KiB
JSON
38 lines
2.8 KiB
JSON
[
|
|
{
|
|
"question": "What is the chain rule in the context of neural networks?",
|
|
"options": ["A technique for batching data", "A method for initializing weights", "A rule for chaining layers together", "If y = f(g(x)), then dy/dx = f'(g(x)) * g'(x) -- multiply derivatives along the path"],
|
|
"correct": 3,
|
|
"explanation": "The chain rule lets you compute the derivative of a composite function by multiplying the local derivatives at each step. Backpropagation applies this systematically through the computational graph.",
|
|
"stage": "pre"
|
|
},
|
|
{
|
|
"question": "Why is backpropagation more efficient than computing each gradient independently?",
|
|
"options": ["It uses less memory", "It computes all gradients in a single backward pass instead of one forward pass per parameter", "It only works on small networks", "It avoids using the chain rule"],
|
|
"correct": 1,
|
|
"explanation": "Computing gradients independently requires one forward pass per parameter (millions of passes for a large network). Backpropagation computes all gradients in one backward pass by reusing intermediate values stored during the forward pass.",
|
|
"stage": "pre"
|
|
},
|
|
{
|
|
"question": "In the backward pass, why do we use '+=' instead of '=' when accumulating gradients?",
|
|
"options": ["It's a Python convention", "A value might be used in multiple operations, so its gradient is the sum of gradients from all paths", "It makes the code run faster", "It prevents overflow"],
|
|
"correct": 1,
|
|
"explanation": "When a Value is used as input to multiple operations (e.g., x used in both x*w1 and x*w2), its total gradient is the sum of the gradients flowing back from each operation. Using += accumulates these correctly.",
|
|
"stage": "post"
|
|
},
|
|
{
|
|
"question": "What causes the vanishing gradient problem in deep sigmoid networks?",
|
|
"options": ["The loss function is poorly chosen", "The network has too many parameters", "The learning rate is too small", "Sigmoid's derivative has a maximum of 0.25, so gradients shrink exponentially through layers"],
|
|
"correct": 3,
|
|
"explanation": "The sigmoid derivative peaks at 0.25 (when z=0). Each layer multiplies the gradient by at most 0.25, so after 10 layers the gradient is at most 0.25^10 = ~0.000001 of the original signal.",
|
|
"stage": "post"
|
|
},
|
|
{
|
|
"question": "Why does topological sort matter in the backward pass?",
|
|
"options": ["It reduces memory usage", "It speeds up the forward pass", "It ensures each node's gradient is fully accumulated before propagating to its children", "It makes the code cleaner"],
|
|
"correct": 2,
|
|
"explanation": "Topological sort ensures we process nodes in the correct order: a node's gradient must be fully accumulated from all downstream paths before we propagate through it. Without this ordering, gradients would be incomplete.",
|
|
"stage": "post"
|
|
}
|
|
]
|