3.1 Shallow and deep networks
1. Learn
Section titled “1. Learn”- Understanding Deep Learning (Prince)chapter 3 Shallow neural networks (pp. 25–40) and chapter 4 Deep neural networks (pp. 41–55)
2. Bridge
Section titled “2. Bridge”Logistic regression from 2.3 draws one straight boundary. A neural network first computes new features, then fits a linear model on them. One hidden layer with weights computes , and the output is . This course stores examples as rows, so a layer is A @ W + b with W of shape (inputs, outputs). UDL writes the same layer transposed, , with examples as columns (UDL §3.1, §4.4).
A shallow net is a sum of hinges. With one input, hidden unit is : flat on one side of and a ramp on the other. The output adds such hinges, so it is piecewise linear with at most pieces (UDL §3.1.1 and §3.2). Add hidden units in the ReLU region viewer and watch each one add a kink.
Universal, but not easy. With enough hinges a shallow net can approximate any continuous function on a bounded region as closely as you like (UDL §3.2; Hornik 1991). The theorem says such weights exist. It does not say how many units you need, or that gradient descent will find them from data.
Depth composes folds. A second layer applies hinges to the first layer’s output, and each one can fold the input space onto itself. The folding weights in the region viewer give pieces from layers of just two units, while one layer with the same number of parameters is limited to (UDL §4.1–4.5; Montúfar et al. 2014). That count is what one construction achieves, not a ceiling (UDL §4.5.2 gives the general bound). Random weights rarely come close, but the extra capacity is why deep networks fit complicated functions with few parameters.
Counting parameters. A layer from to units has weights and biases. The playground’s readout counts them for you. The initial weights matter too: He initialisation draws them with variance so that activations neither shrink nor blow up with depth, which module 3.4 explains (UDL §7.5).
3. Explore
Section titled “3. Explore”Try circles with 0 hidden layers, then 1 layer of 2 units, then 1 layer of 4. Then try the spiral: compare 1 layer of 8 units with 3 layers of 4.
Write ReLU, He initialisation and the forward pass for any list of layer sizes, keeping a cache that module 3.2 will need for backprop. Then count linear pieces numerically and check both claims from the Bridge: at most for one layer, and for the folding network.
stubs/m3_1_mlp.pyLoading starter file…
Prefer your own editor? Edit exercises/stubs/m3_1_mlp.py and run mlc check 3.1. The tests are identical; import the results on the progress page.
Locally: mlc check 3.1.
5. Check
Section titled “5. Check”- not yet: All tests pass (0/?)
- not yet: Checkpoint quiz ≥ 80%
Learner log: time spent and points of confusion
Every confusion you note becomes a fix before the module is marked stable. Export it from the progress page and attach it to an issue.