Section 1 - Instruction

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"?

Section 2 - Instruction

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?

Section 3 - Instruction

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?

Section 4 - Instruction

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?

Section 5 - Instruction

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.

Section 6 - Instruction

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?

Section 7 - Practice

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
Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal