Module 20 · Inside a Neural Network

How do millions of weights end up set correctly?

Lesson 20.3 · Hotter, Colder

Felix · Rosa

Guess. Check the error. Nudge every weight a little toward less error. Repeat.

Felix and Rosa are stuck on the same thing: nobody could set a million weights by hand.

Felix’s guess is that the computer tries random settings until one works.

Rosa points out that would take longer than the universe has been around.

The real method is “hotter, colder,” played a few million times.

The short answer

By being wrong a million times and slightly less wrong each time. Guess, measure the error, nudge every weight toward less error, repeat. No one sets them. They settle. Felix’s random-guessing plan would still be running when the sun burns out.

Try it yourself

Step through a few rounds of training and watch the error meter fall.

Error
92

Round 0. Random weights. The network guesses “layup” for everything. Error is enormous.

Step 1 of 4
See it in 3DHow a neural network learns, one nudge at a time

What you just did has a name

Gradient descent and backpropagation

Training measures how wrong the network is (the loss), works out for every weight which direction would reduce it (the gradient), and nudges each weight a small step that way.

Backpropagation is the bookkeeping that computes all those directions at once, layer by layer from the output backward.

Repeat until the loss stops falling.

A few more things

“Hotter, colder” with a million dials

You don’t try random settings. You check which way each dial should turn to make the answer a bit better, turn all of them a little, and check again. Every dial moves every round. That’s the trick that makes it feasible.

Small steps, many times

Big nudges overshoot. Tiny nudges take forever. The step size is a knob someone tunes, and getting it wrong is the most common reason training fails. The rounds go into the millions for big models.

This is the expensive part

Every round means running every training example through the network and back. For a chatbot-sized model on trillions of words, that’s months on thousands of specialized chips. Module 23 follows the bill.

Go deeper

The longer version, if you want it.

Why it works at all

The loss is a single number, and every weight affects it. Calculus gives the slope of the loss with respect to each weight, and the chain rule lets you compute all of those slopes efficiently by passing the error backward through the layers. That’s backpropagation, published in its modern form in 1986 and unchanged in principle since.

What changed is scale. The same algorithm on 1980s hardware trained networks with hundreds of weights. On today’s chips it trains networks with hundreds of billions. The idea was always fine. It was waiting for the computers.

Quick check

A network guesses a photo is 90 percent “cat.” It’s a dog. What happens to the weights next?

Let’s take it slower

Picture a blindfolded hiker trying to reach the bottom of a valley. She can’t see the map, but she can feel which way the ground slopes under her feet. So she takes a small step downhill, feels again, steps again. The height of the ground is how wrong the network is. Each direction she could step is one weight. Backpropagation is the part that tells her, for all million directions at once, which way is downhill. Small steps, checked constantly, beat one big jump.

More examples

1

Tuning a guitar by ear

You pluck the string, hear it’s flat, tighten a little, check again, and back off a hair when it goes sharp. You never knew the exact right tension. You only knew which direction was less wrong, and you took small steps until the error stopped shrinking.

2

Your keyboard’s autocorrect

Every time you tap the little x to reject a suggestion, that’s an error signal. The model behind the keyboard shifts a bit away from the word it offered and toward the one you typed. One rejection barely moves it, but a month of them is why it finally stopped changing your friend’s name.

Back to the question

So how do a million weights end up set correctly?

Show the answer

By being wrong a million times and slightly less wrong each time. Guess, measure the error, nudge every weight toward less error, repeat. No one sets them. They settle. Felix’s random-guessing plan would still be running when the sun burns out.

One last question

How does training set the weights?

Talk Card

Talk Card · 20.3

Training compares each guess to the right answer and nudges every weight a little toward less error. Millions of nudges is why it needs serious computing power.

Data to AI · pettigrewlab.com/learn

Next lesson