Prediction Before Learning
Before a model can learn, it must make a prediction.
This is the basic order:
input -> prediction -> loss -> gradient -> update
The prediction comes first because the model needs something to compare with the target.
Suppose:
x = 2
y = 9
w = 3
b = 1
The model predicts:
y_hat = wx + b
= 3 x 2 + 1
= 7
Only after computing y_hat can we ask how wrong the model was.
error = y_hat - y
= 7 - 9
= -2
This page does not yet explain how gradients update w and b. It only fixes the order: prediction first, learning signal after.
Let y_hat = wx + b, with x = 3, w = 4, b = -1, and target y = 10. What is y_hat?
Compute it first, then check your number.
HintPredict first
Use the model before comparing with the target.
SolutionWork it out
y_hat = 4 x 3 - 1 = 12 - 1 = 11.
Using the same prediction y_hat = 11 and target y = 10, compute y_hat - y.
Compute it first, then check your number.
HintUse signed error
Compute prediction minus target.
SolutionWork it out
y_hat - y = 11 - 10 = 1.