12.2 Multilayer Neural Networks
Hidden layers and a composition of linear maps and nonlinearities.
These notes walk through the lecture slides. The original deck is unchanged; use (slides) on the course hub if you want that PDF.
Figures and notes follow Géron, Hands-On Machine Learning; Deisenroth, Faisal, and Ong, Mathematics for Machine Learning; Theodoridis; and 3blue1brown.
1. A multi-layer net
A multi-layer perceptron stacks dense layers. Below: pixels of a digit flatten to an input vector, then hidden layers, then class scores.

2. What the layers are doing
Think of a deep net as multistage distillation: each layer filters the previous representation; what remains is more useful for the task.

3. Linear-algebra notation
Weights, activations, and the next layer line up as matrix–vector products. The picture is the notation you will write.

4. Mathematics of a layer
Linear map. Neuron does not see raw after the first layer. It sees the previous activations :
where is the pre-activation, the weight matrix, the bias.
Activation. Elementwise nonlinearity:
Without , stacked layers collapse to one linear map. The nonlinearity is what a hidden layer is for.
5. Activation functions
Common choices: sigmoid, tanh, ReLU, softmax. Applied elementwise after the linear map (softmax on the output for mutually exclusive classes).

Practice
-
Write the forward pass of a two-layer net in one line of matrix products.
-
If you drop from every hidden layer, what class of functions can the net represent?
-
In , what is ?