Sunday, 06 September 2026
Advertisement Advertise Your advert could be here Reach thousands of learners and ICT professionals across Rwanda. Contact us
Advertisement Opportunity Jobs, scholarships & hackathons Fresh openings from Rwandan job boards are pulled in every hour. See openings

How a machine actually learns

Artificial intelligence from zero · lesson 2 of 12

In this lesson: Explain training, weights and error correction without using jargon.

"The machine learns" sounds mystical. It is not. It is guessing, measuring how wrong the guess was, and adjusting. Millions of times.

A model is a big pile of numbers

Suppose you want to predict a student's exam mark from two facts: hours studied, and attendance percentage. A very simple model is:

predicted_mark = (a × hours_studied) + (b × attendance) + c

Here a, b and c are weights. Choosing good numbers for them is the model. Training means finding them.

The training loop

The computer does exactly this, over and over:

  1. Guess. Start with random weights. Predict a mark for a student whose real mark you already know.
  2. Measure the error. Predicted 40, actual 70 — the error is 30. This measurement is called the loss.
  3. Nudge the weights a small amount in whichever direction makes that error smaller.
  4. Repeat with the next student. And the next. And the next, for millions of rounds.

The nudging step has a name — gradient descent — and it is the single most important algorithm in modern AI. The idea is the same as finding your way downhill in fog: you cannot see the valley, but you can feel which way the ground slopes, so you step that way and repeat.

This is why AI needs so much data and electricity. A real model has billions of weights, not three, and each training round adjusts all of them. That is not clever — it is enormous arithmetic done very fast.

Neural networks, briefly

Our example combined the inputs once. A neural network stacks that step in layers: the first layer combines the raw inputs, the second layer combines the results of the first, and so on. Each layer can express something more abstract than the one below it. In an image model the early layers react to edges, the middle layers to shapes like an eye or a wheel, the late layers to "cat" or "car". Nobody programmed those stages; they emerged because they were useful for reducing error.

The three ways a machine can be taught

StyleWhat it is shownEveryday example
SupervisedExamples with correct answers attachedSpam filter, exam-mark prediction
UnsupervisedData with no answers — find the structureGrouping customers into segments
ReinforcementNo answers, only rewards for good outcomesGame-playing, robot control

The failure you must know: overfitting

A student who memorises past papers scores well on those papers and badly on a new one. Models do the same thing. A model that has memorised its training data instead of learning the pattern is overfitted: excellent on data it has seen, useless on data it has not.

The defence is simple and non-negotiable: hold back some data the model never trains on, and judge it only on that. If someone tells you their model is 99% accurate and cannot tell you what it scored on held-back data, they have told you nothing.

Try it yourself

On paper, guess values for a, b and c above. Take a student with 10 hours and 80% attendance who actually scored 65. Compute your prediction, find the error, and adjust one weight to shrink it. You have just done, by hand, what training does billions of times.

Create a free account to save progress

All lessons in this track

  1. 1
  2. 2
  3. 3
  4. 4
    What a language model is really doing ~20 min account needed
  5. 5
  6. 6
    Writing a prompt that actually works ~20 min account needed
  7. 7
    When AI is confidently wrong ~20 min account needed
  8. 8
  9. 9
    What never to paste into an AI tool ~15 min account needed
  10. 10
  11. 11
  12. 12
    AI careers, and where to go from here ~15 min account needed
Advertisement Yanjye Learn a new digital skill this week ICT, programming and professional courses with graded weekly assignments. Start free