Monash University · FACULTY OF COMPUTER SCIENCE

ECE5179 Chap.4 Multilayer Perceptrons and Backpropagation

- one subject, every graph, every model, every mark
8 Chapters6-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 4 of 12 · ECE5179

Multilayer Perceptrons and Backpropagation

Week 4 builds the first deep networks. A multilayer perceptron alternates affine maps with non-linear activations; without the activations, any stack of layers collapses to a single linear map.

The chapter counts parameters, states what such networks can represent, and then derives backpropagation as the chain rule applied backwards through a computation graph, with a full forward and backward pass and the constructive design questions that recur in tests.

In this chapter

What this chapter covers

  • 01

    Why stacked linear layers collapse

  • 02

    Sigmoid, tanh, ReLU and smoother activations

  • 03

    MLP anatomy and parameter counts

  • 04

    Universal approximation and the role of depth

  • 05

    The chain rule on a computation graph

  • 06

    Local gradient rules for linear, ReLU and sigmoid nodes

  • 07

    Building Boolean functions and regions from simple units

  • 08

    Training loops in PyTorch and the Adam optimiser

Worked example · free

Forward values and local gradients on a computation graph

Q [6 marks]. Inputs x1 = 1 and x2 = −2 feed a = wᵀx with weights w1 = 0.5 and w2 = 0.25; then h = σ(a), z = 3h and L = ½(z − 1)². Find ∂L/∂v for the output weight v = 3 and the gradients for w1 and w2. The weighting used for these marks is our own, not the University's assessment scheme.
The worked example as a computation graph.The worked example as a computation graph. Blue arrows and values show the forward pass from inputs to loss; red arrows carry gradients back, each one the product of the gradient above and a local derivative.x1, x2a = wᵀxh = σ(a)z = v·hLa = 0.00h = 0.50z = 1.50L = 0.125∂L/∂a = 0.375∂L/∂h = 1.50∂L/∂z = 0.50
The worked example as a computation graph. Blue arrows and values show the forward pass from inputs to loss; red arrows carry gradients back, each one the product of the gradient above and a local derivative.
  • 1Forward values: a = 0, h = σ(0) = 0.5, z = 1.5 and L = 0.125.
  • 1Seed the backward pass: ∂L/∂z = z − 1 = 0.5.
  • 1Output weight: ∂L/∂v = 0.5 × h = 0.25.
  • 1Into the hidden unit: ∂L/∂h = 0.5 × v = 1.5, then ∂L/∂a = 1.5 × σ(0)(1 − σ(0)) = 0.375.
  • 1First weight: ∂L/∂w1 = 0.375 × x1 = 0.375.
  • 1Second weight: ∂L/∂w2 = 0.375 × x2 = −0.75.
∂L/∂v = 0.25, ∂L/∂w1 = 0.375 and ∂L/∂w2 = −0.75. Both input-weight gradients share the factor 0.375 and differ only by the input they multiply.
Sia tip — Tabulate every forward value before the backward pass; each local derivative uses those stored numbers, and recomputing them mid-derivation is where slips happen.
Glossary

Key terms

Activation function
An activation function is the fixed non-linearity applied elementwise after each affine layer of a network.
ReLU
ReLU outputs its input when positive and zero otherwise, so its derivative is 1 or 0.
Universal approximation theorem
The universal approximation theorem says a sufficiently wide single hidden layer can come arbitrarily close to every continuous function on a compact set.
Computation graph
A computation graph records each operation of a model as a node so that derivatives can be propagated along its edges.
Vanishing gradient
A vanishing gradient is a gradient that shrinks towards zero as it is multiplied through many layers.
Dying ReLU
A dying ReLU is a unit whose input stays negative, so it outputs zero and passes no gradient.
FAQ

Multilayer Perceptrons and Backpropagation FAQ

Why do neural networks need activation functions?

Without them, each layer is an affine map and a composition of affine maps is still affine, so the whole network can only draw flat decision boundaries. The non-linearity between layers is what lets hidden layers bend the input space and build features that a final linear layer can separate.

How do I count the parameters of an MLP?

Each layer from n inputs to m outputs has n times m weights plus m biases. Add the layers together. For example, 12 to 16 to 16 to 4 holds 208 plus 272 plus 68, which is 548 parameters. Activation functions add none.

What does backpropagation actually compute?

It finds how the loss changes with each weight in one backward sweep, multiplying local derivatives along each path from the loss and adding contributions where paths meet. Its cost is roughly one extra forward pass, which is why gradient descent on large networks is practical.

Why can a single ReLU unit not compute XOR?

A single unit thresholds one linear score, so its positive region is one side of a line. XOR is positive on two opposite corners of the square and negative on the other two, which no single line can separate. One hidden layer of two or more units fixes this by combining two boundaries.

What does the universal approximation theorem not tell you?

It guarantees that a sufficiently wide single hidden layer can come arbitrarily close to every continuous function on a bounded region, but it does not say how wide that layer must be, whether gradient descent will find the right weights, or whether the result will generalise to new data. Depth often achieves the same accuracy far more economically.

Study strategy

Exam move

Draw the computation graph before writing any derivative, then fill a forward table and a backward table side by side. Practise on graphs with a branch, where a value feeds two later nodes, so the add-where-arrows-meet rule becomes automatic. Count parameters for several made-up architectures and confirm each count by a second method.

For design questions, rehearse the ReLU identities for absolute value and identity and the pattern-detector construction for Boolean functions. When a question asks for a gradient with respect to an input rather than a weight, use the same graph and swap the final factor: ∂L/∂x comes from Wᵀ times the upstream gradient.

Practising both directions on the same small network is the quickest way to make the linear-layer rules automatic.

Working through Multilayer Perceptrons and Backpropagation in ECE5179? Sia is AskSia’s AI Computer Science tutor — ask any ECE5179 Multilayer Perceptrons and Backpropagation question and get a clear, step-by-step explanation grounded in how ECE5179 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 161 of your Monash University subjects - and 1,000+ Bibles across every Australian university.
Sia - your ECE5179 tutor, unlimited, worked the way the exam marks it
The full 6-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works
ECE5179 · Neural networks and deep learning - independent study guide on the AskSia Library. More Monash University subjects · Microeconomics across all universities