Loss: How a Network Knows It Got It Wrong
A network starts with random weights, which means it starts by being wrong about everything. To improve, it needs something more useful than the knowledge that it failed. It needs a number saying how badly it failed, because a number can be pushed down.
That number is called the loss, and it is the single most important quantity in training. Everything the network does to improve is a reaction to it.
What You'll Learn
- What loss measures and why training needs a number rather than a verdict
- Why "how confident were you" beats "were you right"
- How loss over one example becomes loss over a whole dataset
- Why the choice of loss defines what the network tries to become
Loss is a wrongness score
The idea is plain. Show the network an example where you already know the correct answer. Let it predict. Compare the prediction to the truth. Turn the gap into a single number.
For something with a numeric answer, the gap is obvious. If a network estimates a house will sell for 300,000 and it actually sells for 250,000, it was off by 50,000. Score that gap and you have the loss for that example. A perfect prediction scores zero, and larger mistakes score higher.
The whole of training is then easy to state: find the weights that make this number small.
Why a right-or-wrong verdict is not enough
Now take a task with categories rather than numbers, like sorting messages into urgent and not urgent. It is tempting to score this by simply counting mistakes. That turns out to be nearly useless for training, and understanding why explains a lot about how learning works.
Imagine the network is 51 percent sure a message is urgent, and it is right. Now imagine it is 99 percent sure, and it is right. Counting correct answers treats these identically. But they are not the same at all. The first is a network that barely knows what it is doing. The second is genuinely confident.
Worse, consider a wrong answer. A network that was 51 percent sure and wrong made a near miss. A network that was 99 percent sure and wrong is confidently, badly broken. A simple mistake count scores both as one error.
So instead, loss for categories measures how much confidence was placed on the correct answer. Being right by a hair still carries meaningful loss. Being wrong with high confidence is punished heavily.
This gives training something a verdict never could: a sense of direction. A pure right-or-wrong score only changes when a prediction flips from one side to the other, so most small weight adjustments would show no effect at all and the network would have no idea whether it was improving. Confidence-based loss responds to every small change, so there is always a signal saying which way is better. The next lesson depends entirely on that property.
From one example to the whole dataset
A single example does not tell you much. A network might do well on one message by luck.
So loss is measured across many examples and averaged. That average is what training actually works to reduce. In practice, networks rarely look at the entire dataset at once, because it would be far too slow. They work through it in small groups, often called batches, computing the average loss for each group and updating the weights before moving to the next.
This is why training progress is usually shown as a loss curve: a line that starts high and falls, quickly at first and then more slowly, as the weights settle into better values. When people say a model is "converging," they mean that curve is flattening out near the bottom.
- PredictNetwork guesses an answer
- CompareCheck against the known answer
- Score the lossOne number for how wrong
- Adjust weightsNudge toward less wrong
- RepeatMillions of times
That loop is the entirety of training. This lesson covers the third box. The next covers the fourth, which is where the real cleverness lives.
The loss defines what "good" means
Here is a point that matters well beyond the technical detail.
The loss function is chosen by people. It is one of the few genuinely human decisions in an otherwise automatic process, and it silently defines what the network will become. A network does not try to be useful, accurate, or fair. It tries to make the loss number small. Whatever that number rewards is what you get.
If your loss treats every mistake as equally costly, the network will treat them as equally costly, even when they clearly are not. In medical screening, missing a real illness and raising a false alarm are both errors, but they carry wildly different real-world consequences. If the loss does not encode that difference, the network will not respect it.
This is one of the most common ways AI systems end up behaving in ways their builders did not intend. The system did exactly what it was asked. It was asked for the wrong thing. If that question interests you, AI Ethics and Responsible AI works through where these choices go wrong in practice.
Low loss is not automatically a good model
One warning to carry into the rest of the course.
A network can drive its loss on the examples it studied down to almost nothing by memorizing them, in the same way a student can memorize an answer key without understanding a single question. On those exact examples it looks flawless. On anything new it falls apart.
Low loss on the training examples is therefore necessary but not sufficient. What you actually care about is performance on examples the network has never seen, which is why models are always tested on data held back from training. The final lesson comes back to this, because it is the real reason data volume matters so much.
Key Takeaways
- Loss is a single number measuring how wrong a prediction was, and training exists to make it small.
- For categories, loss measures confidence in the correct answer, not just whether the answer was right.
- Confidence-based scoring gives training a sense of direction, which a simple right-or-wrong count cannot provide.
- Loss is averaged over batches of examples, producing the falling loss curve seen during training.
- The loss function is a human choice that defines what the network optimizes for, and getting it wrong produces a model that confidently does the wrong thing.

