AI Anatomy Class · Part 2 · How machines learn
20. How wrong was it? Loss
Q. We know when an AI is wrong, but how do we measure how wrong it is?
- The chapter 16 neuron guessed Truck A would get 3.5 points. But the real rating our friends gave after eating there is 4.5.
- How wrong it is = the distance between the dart and the target. Guess minus answer: 3.5 − 4.5 = −1. It fell 1 point short.
- Let's grade three trucks: A is −1, B is +1, C is −0.5. Simply adding them gives −0.5, which looks almost right.
- To get rid of the signs, we square each error. Absolute values would work too, but squaring punishes big misses much more.
- The mean of the squares is 2.25 ÷ 3 = 0.75. This single number is the loss. A loss of 0 means everything was right.
- GPT guesses the next word, not a rating, so it's graded on how much probability it gave the right word. That's chapter 65.
- Now we have a goal: find the knobs that bring the loss close to 0. Chapter 21 shows how.
Chapter summary
- Error = guess − answer. Simply adding errors lets + and − cancel out.
- So we square them (or take absolute values) and average. That one number is the loss.
- Loss 0 = all correct. Learning = finding knobs that shrink the loss. GPT's loss is in chapter 65.