Exercises

These exercises check the MLP ideas from the chapter.

Exercise: Hidden shape

X has shape (16, 5) and W1 has shape (5, 9). What is the shape of H = relu(XW1 + b1)?

Compute it first, then check your number.

Exercise: Output score shape

H has shape (16, 9) and W2 has shape (9, 4). What is the score matrix shape?

Compute it first, then check your number.

Exercise: Count layers

An MLP has input size 8, one hidden layer with 12 units, and one output layer with 3 units. How many learned layers does it have?

Compute it first, then check your number.

Exercise: Apply hidden ReLU

A hidden pre-activation vector is [2, -5, 1]. After ReLU, how many values are positive?

Compute it first, then check your number.

Exercise: Regression output

A regression MLP processes a batch of 25 examples and produces one number per example. What is the output shape?

Compute it first, then check your number.

Exercise: Classification output

A classifier processes 25 examples and has 6 classes. What is the score matrix shape?

Compute it first, then check your number.