Exercises

These exercises check the loss-function ideas from the chapter.

Exercise: Signed error

A model predicts 6, and the target is 10. Compute prediction - target.

Compute it first, then check your number.

Exercise: Squared error

A prediction is 2, and the target is 5. What is the squared error?

Compute it first, then check your number.

Exercise: Mean squared error

Squared errors are [4, 4, 1]. What is their mean?

Compute it first, then check your number.

Exercise: True-class probability

Probabilities are [0.1, 0.2, 0.7]. The true class is class 3. What is p_true?

Compute it first, then check your number.

Exercise: Stable softmax shift

Shift logits [4, 1, -2] by subtracting the maximum. What is the second shifted value?

Compute it first, then check your number.

Exercise: Choose the loss

A model chooses one of 8 classes. Enter 1 for multiclass cross-entropy as the usual first choice, or 0 for mean squared error.

Compute it first, then check your number.