Lai Learns Neural Networks

Lesson 01·Chess·4 min read

Of the Thinking Engine, and How It Learneth Its Game

What a neural network is: a machine that learns patterns from examples instead of following written rules

“No master of the board was ever handed his art. He played, and lost, and played again, until the right move came to him the way a familiar face does: without his asking.”

Invented, in the spirit of Marcus Aurelius

Welcome

Let’s begin somewhere quiet: a chessboard, two players, a slow afternoon. You don’t need to know anything about computers for this lesson. You only need to know roughly how chess works, and even that is optional.

Two ways to teach a machine chess

Imagine you want to build a machine that plays chess. There are two ways you could go about it.

The first way is to write rules. You sit down and write instructions: “Protect your king. Control the centre. A knight is worth about three pawns.” You keep writing until you’ve covered every situation you can think of. This works, up to a point. But chess has more possible games than there are atoms in the universe, and no one can write a rule for all of them. Sooner or later, the machine meets a position you never imagined, and it has nothing to say.

The second way is to let it learn. Instead of writing rules, you show the machine thousands of games. Millions, even. After each move it makes, you tell it, gently, whether that turned out well or badly. At first its moves are clumsy, almost random. But little by little, it starts to notice things. Certain shapes on the board tend to lead to wins. Certain moves tend to lead to trouble. Nobody told it these things. It found them.

That second way is what a neural network does.

So what is a neural network?

In one line

A neural network is a machine that learns patterns from examples, rather than following rules someone wrote down.

That’s really all it is. Everything else in this course, every lesson to come, is about how it manages that.

It might help to notice that this is how you learned most of what you know. Nobody gave you a rulebook for recognising your mother’s face, or knowing when a friend is upset, or catching a ball. You saw examples, you made mistakes, and something inside you adjusted. Neural networks are loosely inspired by that same idea, which is where the word “neural” comes from.

The three pieces to hold onto

Every neural network, from the tiniest to the ones that write essays, has the same three pieces. In chess terms:

  1. What it sees. The board in front of it: where every piece stands. We call this the input.
  2. What it decides. The move it chooses to make. We call this the output.
  3. How it improves. After many games, it adjusts itself so its good moves become more likely and its bad ones less likely. We call this learning, or training.

In between the input and the output, there’s a sort of inner workshop where the network turns “what I see” into “what I’ll do.” That workshop is made of small, simple parts, and we’ll open its door in the next lesson.

What to carry with you

If you remember only one sentence from today, let it be this: a neural network learns from examples instead of following rules. You already understand the most important idea in the whole course.

Next time

We’ll leave the chessboard and kneel beside a termite mound. One termite is not very clever at all, and yet together they build cathedrals of mud. That turns out to be exactly how the inside of a neural network works.