Swipe long formulas, tables or code sideways to see the rest.
Start here All of Week 3 on one page: feedforward
networks, output/loss choices, and backpropagation.
- A feedforward network computes ak=bk+Wkhk−1 and hk=g(ak) for each hidden layer, then y^=O(aL).
- Parameters θ= all Wk and bk; learned by gradient descent, θ ← θ−η∇θ.
- Real-valued outputs → linear output + squared
error. Classes → softmax + cross-entropy (L=−logy^_ℓ).
- Backpropagation passes blame from the loss down
through the layers using the chain rule.
- With softmax + cross-entropy, the output gradient is just y^−e(ℓ).
| Idea |
Formula |
| Pre-activation |
ak=bk+Wkhk−1(h0=x) |
| Activation |
hk=g(ak);y^=O(aL) |
| Softmax |
y^j=eaLj/∑ieaLi |
| Cross-entropy |
L=−∑cyclogy^c=−logy^ℓ |
| Gradient w.r.t. y^ |
∇y^L=−(1/y^ℓ)e(ℓ) |
| Output gradient |
∇aLL=−(e(ℓ)−y^) |
| Hidden units |
∇hk−1L=WkT∇akL |
| Through activation |
∇ak−1L=∇hk−1L⊙g′(ak−1) |
| Weights |
∇WkL=∇akL⋅hk−1T |
| Biases |
∇bkL=∇akL |
| Sigmoid derivative |
σ′=σ(1−σ) |
| tanh derivative |
tanh′=1−tanh2 |
| Thing |
Shape |
| Wi (hidden, n units each) |
n×n |
| WL (k outputs) |
k×n |
| bi/bL |
n / k |
| ∇Wk |
same as Wk |
- ∇y^L (only one non-zero entry, −1/y^_ℓ) is not the same as ∇aLL (ŷ − e(ℓ), all entries non-zero).
- Use WT (transpose) when passing gradients
down.
- ⊙ is element-wise, not a matrix product.
- Sigmoid output can’t predict values outside (0, 1) → use linear for
real values.
- The entries of y^−e(ℓ) always add to 0.
- Slide erratum: one slide writes ∇WL∈Rn×k; it should be k×n, the same as WL.
Exam words: feedforward network, pre-activation,
activation, output function, linear output, softmax, cross-entropy,
log-likelihood, backpropagation, chain rule, one-hot vector, outer
product, element-wise product, forward/backward propagation.
- What does softmax guarantee about its outputs?
All are positive and they add up to 1 — a probability distribution.
- y^=[0.5,0.3,0.2], true class 1. Loss and ∇aL?
L=−ln0.5=0.693.∇aL=[−0.5,0.3,0.2].
- Write ∇Wk in terms of ∇ak and hk−1.
∇Wk=∇akhk−1T (outer product).
- A sigmoid hidden unit has output 0.3. What is g′?
0.3×0.7=0.21.
- Order the steps: update, backward pass, forward pass.
Forward pass → backward pass → update.