{ "questions": [ { "stage": "pre", "question": "What does the chain rule in calculus state?", "options": ["Functions can only be differentiated if they are linear", "The derivative of composed functions is the product of their individual derivatives", "The derivative of a sum is the sum of derivatives", "The integral of a product is the product of integrals"], "correct": 1, "explanation": "For y = f(g(x)), the chain rule says dy/dx = f'(g(x)) * g'(x). You multiply the derivatives at each link in the chain. This is the mathematical basis of backpropagation." }, { "stage": "pre", "question": "What is a computational graph?", "options": ["A directed graph where nodes are operations and edges carry values forward or gradients backward", "A diagram showing the architecture of a neural network", "A graph database used for storing training data", "A plot of loss vs training steps"], "correct": 0, "explanation": "A computational graph represents the sequence of operations in a computation. Data flows forward through the graph, and gradients flow backward during backpropagation." }, { "stage": "post", "question": "Why does PyTorch use reverse-mode autodiff (backpropagation) instead of forward-mode?", "options": ["Forward mode cannot handle non-linear functions", "Reverse mode computes all gradients in one backward pass, while forward mode needs one pass per input variable -- neural networks have millions of inputs but one loss output", "Reverse mode is more numerically accurate", "Reverse mode uses less memory"], "correct": 1, "explanation": "Neural networks have millions of weight inputs but produce a single scalar loss. Reverse mode needs one backward pass total. Forward mode would need one pass per weight -- millions of passes -- making it impractical." }, { "stage": "post", "question": "In the Value class autograd engine, why does the backward function use '+=' instead of '=' for accumulating gradients?", "options": ["Because a value used in multiple operations receives gradient contributions from each one, which must be summed", "To average the gradients across multiple samples", "To prevent numerical overflow in the gradients", "Because Python does not support the '=' operator in closures"], "correct": 0, "explanation": "When a value feeds into multiple operations (e.g., x used in both x*y and x+z), its total gradient is the sum of all incoming gradient contributions. Using '=' would overwrite earlier contributions." }, { "stage": "post", "question": "What is gradient checking and when should you use it?", "options": ["Checking that gradients are below a threshold to prevent exploding gradients", "Comparing autodiff gradients against numerical finite-difference gradients to verify correctness of the backward pass", "Checking that all parameters received non-zero gradients during training", "Monitoring gradient magnitudes during training to detect vanishing gradients"], "correct": 1, "explanation": "Gradient checking computes numerical derivatives via (f(x+h) - f(x-h)) / 2h and compares them to autodiff gradients. Use it when adding new operations to your autograd engine or debugging training failures." } ] }