Katkat

Implement and Debug Backprop in NumPy

OpenAISoftware Engineer · Technical Screen

Last updated

This question evaluates understanding of backpropagation and the chain rule, proficiency in vectorized NumPy implementation, numerical stability of softmax/cross-entropy, and competency in gradient checking and debugging of model gradients.

Derive backpropagation for a two-layer neural network (Affine → ReLU → Affine → softmax). Write NumPy (Python 3. 7) code to compute the forward pass, loss, and analytical gradients without automatic differentiation using vectorized linear algebra. Implement gradient checking via finite differences and demonstrate how you would debug and fix a mismatch between analytical and numerical gradients. Clearly state tensor shapes at each layer, show the chain rule application, and explain any linear algebra identities used (e.g., broadcasting rules, transpose of products).