Deep LearningIntermediate20 min read5 questions

Neural Networks & Backpropagation From First Principles

Derive backprop, explain why ReLU replaced sigmoid, and know exactly which initialisation to use and why — the three things every deep-learning interview verifies.

Covers: Backpropagation, activation functions, vanishing/exploding gradients, weight initialization, dead ReLUs

Deep-learning interviews almost always include one question you cannot bluff: derive something. Backpropagation through a small network is the standard choice, because it simultaneously tests calculus, tensor shapes, and whether you understand why training diverges.

Filter
0/5 mastered
Advancedbackpropagationchain-rulederivationAsked at Anthropic, OpenAI

30-second answer

Forward: z1 = xW1 + b1, a1 = ReLU(z1), z2 = a1W2 + b2, p = softmax(z2). Backward: dz2 = p − y (the softmax/cross-entropy cancellation), dW2 = a1ᵀ dz2, da1 = dz2 W2ᵀ, dz1 = da1 ⊙ 1[z1 > 0], dW1 = xᵀ dz1. Biases are the batch-sums of the corresponding dz.

IntermediateactivationsrelugeluAsked at Meta AI, Google

30-second answer

Sigmoid saturates at both ends, so its derivative peaks at 0.25 and gradients vanish through depth; it is also not zero-centred. ReLU has a derivative of exactly 1 on the positive side, which preserves gradient magnitude and is trivially cheap — but it can die. GELU and SiLU/Swish are smooth, non-monotonic variants that consistently train transformers better, and SwiGLU (a gated variant) is the current default in most large language models.

Advancedinitializationvariancetraining-stabilityAsked at OpenAI, NVIDIA

30-second answer

Initialisation sets the variance of activations and gradients at layer 1. If the per-layer variance multiplier is not ≈1, signals grow or shrink exponentially with depth. Xavier/Glorot keeps variance stable for symmetric activations like tanh (var = 2/(fan_in+fan_out)); He uses var = 2/fan_in to compensate for ReLU zeroing half the inputs. All-zero init is fatal because every unit in a layer computes the same gradient forever.

AdvancedbatchnormlayernormrmsnormAsked at Google, Meta AI

30-second answer

BatchNorm normalises each feature across the batch, so it depends on batch statistics and breaks with small batches, variable sequence lengths and autoregressive inference. LayerNorm normalises across features within each token independently, so it is batch-size independent — essential for sequences. RMSNorm drops the mean-centring and the bias, keeping only the scale, which is ~10-15% faster with no measurable quality loss. Modern transformers use pre-norm placement for training stability.

Intermediatecnnresnetreceptive-fieldAsked at Tesla, Apple

30-second answer

A convolution slides a small learned kernel across the input, giving translation equivariance and massive parameter sharing versus a dense layer. The receptive field is the input region influencing one output unit; it grows linearly with depth for stride-1 convs and exponentially with dilation. ResNet's skip connections make each block learn a residual F(x) so the layer output is x + F(x) — the identity path lets gradients flow directly to early layers, which is what enabled 50–1000 layer networks.

Showing 5 of 5 questions for neural-networks-and-backpropagation.

Check your understanding

5 questions · no sign-up, nothing stored

0/5 answered
Question 1

1.For softmax + cross-entropy, ∂L/∂z (logits) equals:

Question 2

2.Sigmoid causes vanishing gradients in deep networks because:

Question 3

3.He initialisation uses variance 2/fan_in rather than 1/fan_in because:

Question 4

4.Transformers use LayerNorm rather than BatchNorm mainly because:

Question 5

5.The original ResNet paper observed that a 56-layer plain network had higher TRAINING error than a 20-layer one. This shows:

Hands-on challenge

Build it — this is what you talk about in a deep-dive round.

Build a neural network library from scratch

Implement forward and backward passes in NumPy for a small framework, then verify every gradient.

Requirements

  • Layers: Linear, ReLU, GELU, LayerNorm, Dropout — each with `forward` and `backward`.
  • Losses: softmax cross-entropy (fused, numerically stable) and MSE.
  • Finite-difference gradient checking for every layer, asserting agreement to 1e-6.
  • Train on a small dataset and reproduce the sigmoid-vs-ReLU gradient decay table from question 2.

Stretch goals

  • Add a residual block and show empirically that a 30-layer residual net trains where a 30-layer plain net does not.
  • Implement gradient checkpointing for a chosen layer and measure the memory/compute trade-off.