Backpropagation — ML Technical Interview Questions & Answers

How neural networks learn by propagating error gradients.

Backpropagation

  • Simple meaning: Backpropagation is how a net learns. Forward: compute guess and loss. Backward: send the error to each weight (“how much did I contribute?”) using the chain rule. Then gradient descent steps.
  • Picture: Output said pass with 0.9, truth is fail. The last layer is most “blamed”, then the one before, like a chain of teachers passing notes backwards.
  • You don’t derive the full calculus in a fresher viva — say: forward loss, backward gradients, update weights. Vanishing gradients = early layers stop learning in a deep sigmoid stack (ReLU helped).
  • Trap: saying backprop is a type of neural net. It is the training algorithm. Trap: mixing it with k-means updates.

Technical Interview Tip: Guess, measure error, send blame backward, step the weights.

Code Examples for Backpropagation

Backpropagation — working example

# One gradient step for y ≈ w*x  (MSE loss)
xs = [1.0, 2.0, 3.0]
ys = [2.0, 4.0, 6.0]
w = 0.0
lr = 0.1
grad = sum(2 * (w * x - y) * x for x, y in zip(xs, ys)) / len(xs)
w = w - lr * grad
print(round(grad, 4), round(w, 4))

Backpropagation — gradient descent updates parameters opposite the loss gradient: w ← w − η∇L.

How to Explain Backpropagation to an Interviewer

Backprop steps?

Forward Loss Backward gradients Update

Vanishing gradient?

Early layers get tiny gradients Hard to learn