AI Hints
Home›Generative AI Tutorial›How Machines Learn
Generative AI · Lesson 4 of 77

Learning From Examples

How a machine finds patterns without being told the rules.

⏱ 2 min read▶ Video at 11:05🎓 Free
Watch this lesson in the Generative AI courseWatch on YouTube ↗Full Generative AI course

How can a machine learn anything at all? In this lesson, you will see that the idea is simpler than you think. A machine learns the way a child does, by looking at many examples, and slowly noticing patterns. By the end, you will know the three ingredients of every learning system.

Learning From Examples
From the video: Learning From Examples
  • How can a machine learn?
  • Like a child: many examples
  • Three ingredients of every learning system

Programming versus learning

In normal programming, a person writes the rules, and the computer follows them. Rules and data go in, and answers come out. Machine learning flips this around. You give the computer the data, and the correct answers, and it works out the rules by itself. Data and answers go in, and the rules come out. Those learned rules are called the model.

Normal programming

  • A person writes the rules
  • Rules + data go in
  • Answers come out
  • Great when rules are easy to state

Machine learning

  • The computer finds the rules
  • Data + answers go in
  • The rules come out: the model
  • Great when rules are hard to state

The learning loop

Here is the learning loop. First, we collect examples, called the training data. Second, the model makes a guess. Third, we compare the guess with the right answer, and measure the mistake. Fourth, the model adjusts itself a tiny bit, to make a smaller mistake next time. Then we repeat this, thousands, or millions of times. Guess, check, adjust. That is all learning is.

  1. 1. Dataexamples with answers
  2. 2. Guessthe model predicts
  3. 3. Checkmeasure the mistake
  4. 4. Adjustimprove a tiny bit
Guess, check, adjust, repeat
The learning loop
From the video: The learning loop

A cat detector, step by step

Let's make this real, with a cat detector. We show the model thousands of photos, each one labelled, cat, or not a cat. At first, its guesses are random, and mostly wrong. After each photo, it adjusts a little. After a million photos, it notices what cats have in common, pointy ears, whiskers, and a certain shape of eyes. Nobody told it those rules. It discovered them.

Show labelled photoscat, or not a cat
Random guesses at firstmostly wrong, and that is fine
Adjust after each photoa little better every time
Discovers the patternears, whiskers, eyes, shapes

Three ways machines learn

There are three main styles of learning. In supervised learning, every example comes with the right answer, like labelled photos. In unsupervised learning, there are no answers, and the machine looks for hidden groups by itself. And in reinforcement learning, the machine learns by trying things, and getting rewards, like a game player. Large language models use a clever mix, which we will meet soon.

StyleWhat the machine getsExample
Supervisedexamples + right answersspam or not spam
Unsupervisedexamples onlygrouping similar customers
Reinforcementrewards for good actionsa game-playing AI

Summary

Good work. Machines learn from examples instead of rules. The loop is simple, guess, check the mistake, adjust, and repeat. And there are three styles of learning, supervised, unsupervised, and reinforcement. Next, we meet the tiny building block, that does all this adjusting, the artificial neuron.

Key takeaways
  • Data + answers in, rules out
  • Guess, check, adjust, repeat
  • Supervised, unsupervised, reinforcement
Next up: Artificial Neurons — the tiny building block of AI