Machine Learning Basics

How Neural Networks Work in Simple Terms

A plain description of neural networks: layers of simple units, adjustable weights and the error signal that teaches them, with no heavy mathematics.

On this page
  1. The name is a loose metaphor
  2. One simple unit
  3. Stacking units into layers
  4. How a network learns
  5. A tiny numerical illustration
  6. Why depth helps, and what it costs
  7. Where they are used
  8. Keeping it in perspective

The name is a loose metaphor

Neural networks were inspired, loosely, by the idea that brains are made of many connected cells. The resemblance ends quickly. A neural network is a piece of software that turns numbers into other numbers using a large number of simple calculations. Nothing about it is biological, and it does not think the way a brain does.

One simple unit

The building block is often called a neuron or unit. It does three small things:

  1. It receives several numbers as inputs.
  2. It multiplies each input by a number called a weight, which says how much that input matters, then adds the results together.
  3. It passes the total through a simple rule, called an activation, that decides how strongly the unit “fires.”

Here is a hypothetical example. A unit looks at two inputs: how many times the word “free” appears in an email and how many links it has. If the weight on the first is large and positive, then more occurrences of “free” push the output up. If a weight is negative, that input pushes the output down. Weights are the main thing that training changes.

Stacking units into layers

One unit can only capture a very simple pattern. The power comes from arranging many units in layers.

  • The input layer holds the raw numbers, such as pixel values or word counts.
  • One or more hidden layers each take the previous layer’s outputs and compute new ones.
  • The output layer produces the answer, such as a score for “junk” or a set of scores for different labels.

Each unit in a layer usually connects to many units in the previous layer, and every connection has its own weight. A real network can have millions or billions of weights. The activation rule between layers matters as well: without it, stacking layers would collapse into one simple calculation, and the network could not capture curved or complicated patterns.

A helpful way to think of the layers is as stages of refinement. In an image model, early layers tend to respond to edges, later ones to shapes, and the last ones to whole objects. That layered pattern is typical of image recognition models.

How a network learns

At the start, the weights are set to small random values, so the network’s answers are essentially guesses. Training then repeats a cycle.

  1. Forward pass. An example goes in, and the network produces an output.
  2. Measure the error. A formula called a loss compares the output with the correct answer and produces a single number: the bigger the mistake, the bigger the number.
  3. Work out the blame. The error is traced backward through the layers to estimate how much each weight contributed. This step is commonly called backpropagation, and it is the learning signal.
  4. Adjust the weights. Each weight is nudged a small amount in the direction that would have reduced the error. The size of the nudge is controlled by a setting known as the learning rate.

After thousands or millions of repetitions, the weights settle into values that give good answers on the training examples. The network was never told the rules. The pattern is stored implicitly in the weights.

A tiny numerical illustration

Suppose, hypothetically, a unit has one input with a weight of 0.5, and the input value is 4, so the unit outputs 2. If the correct answer was 3, the output is 1 too low. Raising the weight to 0.75 gives 4 times 0.75, which is 3, a match. Training does this kind of adjustment, but for a huge number of weights at once and with many examples pulling in different directions, so each weight is only moved a little at a time.

Why depth helps, and what it costs

Networks with many hidden layers are called deep networks, which is where the term deep learning comes from. Extra layers allow the model to build complicated features from simpler ones. But there are costs.

  • They usually need a lot of training data and computing power.
  • They are hard to inspect. It is difficult to say why a particular set of weights produces a particular answer, which makes explanations and audits harder.
  • They can memorize examples. This risk is known as model overfitting.
  • They reflect their data, including its gaps and skews.

Where they are used

Neural networks power much of today’s speech recognition, image recognition and recommendation systems. The language models behind generative AI tools are also very large neural networks, trained to predict what comes next in a piece of text. Different tasks use different arrangements of layers, but the cycle of guess, measure and adjust is much the same.

Keeping it in perspective

A neural network is a flexible pattern-fitting machine. It can approximate very complicated relationships when it is given enough good examples, and that is its main strength. It does not come with common sense or an understanding of the world, which is why careful testing still matters. If you remember the three ideas of layers, weights and an error signal, you have the core of how most of these systems work.

The complete guide to machine learning basics

Machine Learning Explained for Beginners
Read the guide

Keep exploring

Guides from other topics

All topics →