We've built neurons and stacked them into networks. But here's the big question: how do we know if our network is any good?
Imagine teaching someone to shoot basketballs. You'd need to measure how far they miss the basket, right?
Engagement Message
How would you measure if a neural network is "missing the target"?
Neural networks need a way to measure their mistakes. We call this a loss function—it tells us "how wrong" our predictions are.
Think of loss as a score that gets bigger when predictions are bad and smaller when they're good.
Engagement Message
What would be a good loss score for perfect predictions?
The most common loss function is Mean Squared Error (MSE).
We take the difference between predicted and actual values, square it (to make negatives positive), then average over all examples.
Engagement Message
Why do we square the errors in MSE instead of using absolute errors?
Let's see MSE in action! Say our network predicts a house costs $200,000 but it actually costs $180,000.
The error is: $200,000 - $180,000 = $20,000
Squared error: ($20,000)² = $400,000,000
For one prediction, MSE = $400,000,000. Big numbers mean big mistakes!
Engagement Message
What would the error be if we predicted $181,000 instead?
Our goal is to minimize loss—make our predictions as accurate as possible. But how do we know which direction to adjust our weights?
This is where gradients come in! A gradient tells us: "If you increase this weight slightly, will loss go up or down?"
Think of it like climbing a hill backwards—you want to go downhill to minimize loss.
The gradient is the derivative of loss with respect to each weight. If the gradient is positive, increasing that weight makes loss worse. If negative, increasing the weight helps!
∂Loss/∂weight = gradient
This tells us both direction (positive/negative) and how steep the slope is.
Engagement Message
If the gradient for a weight is positive, should you increase or decrease that weight to reduce loss?
Type
Fill In The Blanks
Markdown With Blanks
Let's calculate MSE! Our network predicts these house prices vs actual prices:
- Predicted: $150,000, Actual: $160,000
- Predicted: $200,000, Actual: $180,000
Calculate: MSE = ½ × [ (150,000 − 160,000)² + (200,000 − 180,000)² ]
Fill in the blanks:
Suggested Answers
- 100,000,000
- 400,000,000
- 250,000,000
- 500,000,000
