ML Foundations

Learn / ML Foundations

ML Foundations: Backpropagation and Neural Network Math

Advanced quiz on chain rule applications, forward and backward passes, activations, softmax, and cross-entropy.

Learning path

0%

0 of 4 sections marked complete · about 31 minutes

Learning objectives

What you will be able to explain

  • Why is the chain rule central to backpropagation?
  • Run a forward pass through a tiny ReLU network
  • What is the derivative of the sigmoid function?
  • Compute a softmax probability
  • Compute a cross-entropy loss value
  • Differentiate a one-neuron squared-loss model

Section 01

Why is the chain rule central to backpropagation? to What is the derivative of the sigmoid function?

01

Why is the chain rule central to backpropagation?

A neural network is a composition of functions. Backpropagation repeatedly applies the chain rule to move gradients from the loss back through each intermediate computation.

Guided checkpoint

Choose the best explanation.

02

Run a forward pass through a tiny ReLU network

The hidden preactivations are z1=1z_1 = 1 and z2=1+41=2z_2 = -1 + 4 - 1 = 2. ReLU leaves both unchanged, and the output becomes 212+1=12 \cdot 1 - 2 + 1 = 1.

Guided checkpoint

Let the input be (x1,x2)=(1,2)(x_1, x_2) = (1, 2). Hidden unit 1 has z1=1x1+0x2+0z_1 = 1 \cdot x_1 + 0 \cdot x_2 + 0, hidden unit 2 has z2=1x1+2x21z_2 = -1 \cdot x_1 + 2 \cdot x_2 - 1, and both activations are ReLU. The output is y^=2a1a2+1\hat{y} = 2a_1 - a_2 + 1. Compute z1z_1, a1a_1, z2z_2, a2a_2, and y^\hat{y}.

03

What is the derivative of the sigmoid function?

The sigmoid derivative can be written in terms of its own output. This compact form is useful in backpropagation derivations.

Guided checkpoint

Choose the correct formula for σ(z)\sigma'(z).

Section 02

Compute a softmax probability to Differentiate a one-neuron squared-loss model

01

Compute a softmax probability

The probability is e2e2+e0=e2e2+10.8808\frac{e^2}{e^2 + e^0} = \frac{e^2}{e^2 + 1} \approx 0.8808. Softmax converts logits into a normalized probability distribution.

Guided checkpoint

For logits (2,0)(2, 0), compute the softmax probability of the first class.

02

Compute a cross-entropy loss value

The cross-entropy loss for the correct class is the negative log of its predicted probability. Here log(0.8)0.22314-\log(0.8) \approx 0.22314.

Guided checkpoint

For a one-hot target on the correct class with predicted probability 0.80.8, compute the cross-entropy loss log(0.8)-\log(0.8) using natural logarithms.

03

Differentiate a one-neuron squared-loss model

The prediction is 22. The output error is (y^y)=3(\hat{y} - y) = -3, so the gradients are 3x=6-3 \cdot x = -6 for the weight and 3-3 for the bias.

Guided checkpoint

Consider a neuron y^=wx+b\hat{y} = wx + b with input x=2x = 2, weight w=1w = 1, bias b=0b = 0, target y=5y = 5, and loss L=12(y^y)2L = \frac{1}{2}(\hat{y} - y)^2. Compute y^\hat{y}, L/w\partial L / \partial w, and L/b\partial L / \partial b.

Section 03

In what order does backpropagation compute gradients? to Match each neural-network quantity to its role

01

In what order does backpropagation compute gradients?

Backprop starts at the loss because that is where the objective is defined. Gradients are then propagated backward to earlier computations using local derivatives.

Guided checkpoint

Choose the best description.

02

Backpropagation facts: true or false

These are standard structural facts about neural-network differentiation. Biases are not multiplied by the input, and backprop generalizes to arbitrarily deep differentiable computation graphs.

Guided checkpoint

Mark each statement as true or false.

03

Match each neural-network quantity to its role

Keeping these roles straight is essential when doing forward-pass bookkeeping and backward-pass differentiation by hand.

Guided checkpoint

Match the term to the best description.

Section 04

Why do sigmoid or tanh networks sometimes suffer from vanishing gradients? to Take one gradient step on a single neuron

01

Why do sigmoid or tanh networks sometimes suffer from vanishing gradients?

When sigmoid or tanh activations saturate, their local derivatives approach zero. Multiplying many small derivatives across layers can shrink gradients dramatically.

Guided checkpoint

Choose the best explanation.

02

Take one gradient step on a single neuron

Gradient descent subtracts the gradient: wnew=10.1(6)=1.6w_{new} = 1 - 0.1(-6) = 1.6 and bnew=00.1(3)=0.3b_{new} = 0 - 0.1(-3) = 0.3.

Guided checkpoint

Using the gradients from the earlier neuron example, update w=1w = 1 and b=0b = 0 with learning rate 0.10.1. The gradients are L/w=6\partial L / \partial w = -6 and L/b=3\partial L / \partial b = -3.

Knowledge check

Turn understanding into recall.

The quiz now follows the same concepts in scored form. You can return to this lesson from the quiz whenever a gap appears.