2/32
Part 1 of 6 · The chain ruleLearn and do
What backprop computes
Start from the forward pass, because the backward pass reads it in reverse.
import numpy as np
rng = np.random.default_rng(0)
N, D, H, K = 6, 4, 5, 3
x = rng.normal(size=(N, D))
y = rng.integers(0, K, size=N)
W1, b1 = rng.normal(size=(D, H)), np.zeros(H)
W2, b2 = rng.normal(size=(H, K)), np.zeros(K)
# hidden layer, before the ReLU
pre = x @ W1 + b1
# after the ReLU
h = np.maximum(pre, 0)
# one score per class
logits = h @ W2 + b2
print(pre.shape, h.shape, logits.shape)
x is (6, 4), W1 is (4, 5) and W2 is (5, 3). What shapes are pre, h and logits?
Pick one to see what it prints.
Pick an answer above to see the rest