Multilayer Perceptron · Module 2

Forward Propagation

How the values flow in the network

Highlighted forward pass: a fully connected 5–4–3–2–1 networkx₃ → a₁⁽¹⁾ → a₁⁽²⁾ → a₁⁽³⁾ → z. Highlighted lines trace one route; all other connections remain visible. The output logit z passes through sigmoid to produce the prediction.Input layer5 featuresHidden layer 14 neuronsHidden layer 23 neuronsHidden layer 32 neuronsOutput layer1 neuronw₁₁⁽¹⁾w₁₂⁽¹⁾w₁₃⁽¹⁾w₁₄⁽¹⁾w₁₅⁽¹⁾w₁₁⁽²⁾w₁₂⁽²⁾w₁₃⁽²⁾w₁₄⁽²⁾w₁₁⁽³⁾w₁₂⁽³⁾w₁₃⁽³⁾w₁₁⁽⁴⁾w₁₂⁽⁴⁾x₁x₂x₃x₄x₅a₁⁽¹⁾a₂⁽¹⁾a₃⁽¹⁾a₄⁽¹⁾a₁⁽²⁾a₂⁽²⁾a₃⁽²⁾a₁⁽³⁾a₂⁽³⁾zz = logitσ(z)σ(z) = p

Calculate the first hidden layer all at once:

z(1)=W(1)x+b(1)z^{(1)}=W^{(1)}x+b^{(1)}
[z1(1)z2(1)z3(1)z4(1)]\begin{bmatrix}z_1^{(1)}\\[8pt]z_2^{(1)}\\[8pt]z_3^{(1)}\\[8pt]z_4^{(1)}\end{bmatrix}4 × 1
=
[w11(1)w12(1)w13(1)w14(1)w15(1)w21(1)w22(1)w23(1)w24(1)w25(1)w31(1)w32(1)w33(1)w34(1)w35(1)w41(1)w42(1)w43(1)w44(1)w45(1)]\begin{bmatrix}w_{11}^{(1)}&w_{12}^{(1)}&w_{13}^{(1)}&w_{14}^{(1)}&w_{15}^{(1)}\\[8pt]w_{21}^{(1)}&w_{22}^{(1)}&w_{23}^{(1)}&w_{24}^{(1)}&w_{25}^{(1)}\\[8pt]w_{31}^{(1)}&w_{32}^{(1)}&w_{33}^{(1)}&w_{34}^{(1)}&w_{35}^{(1)}\\[8pt]w_{41}^{(1)}&w_{42}^{(1)}&w_{43}^{(1)}&w_{44}^{(1)}&w_{45}^{(1)}\end{bmatrix}4 × 5
×
[x1x2x3x4x5]\begin{bmatrix}x_1\\[8pt]x_2\\[8pt]x_3\\[8pt]x_4\\[8pt]x_5\end{bmatrix}5 × 1
+
[b1(1)b2(1)b3(1)b4(1)]\begin{bmatrix}b_1^{(1)}\\[8pt]b_2^{(1)}\\[8pt]b_3^{(1)}\\[8pt]b_4^{(1)}\end{bmatrix}4 × 1
a(1)=f ⁣(z(1))a^{(1)}=f\!\left(z^{(1)}\right)

This 4 × 1 activation vector is the input to the next layer:z(2)=W(2)a(1)+b(2)\quad z^{(2)}=W^{(2)}a^{(1)}+b^{(2)}.

z=W(4)a(3)+b(4)p=σ(z)=11+ezz=W^{(4)}a^{(3)}+b^{(4)}\qquad\longrightarrow\qquad p=\sigma(z)=\frac{1}{1+e^{-z}}

In both modules, ff is the activation function applied to each hidden neuron. The output uses sigmoid.