NeuronCanvas
Neural Networks
Foundations

What Is a Neural Network?

A first, no-math mental model for what a neural network is and why it can learn from examples.

Step 01 - The break

A one-line rule, and the four days it gets wrong

Here is a rule for deciding whether to carry an umbrella. It has one line in it and nothing in it learns.

RULE - bring the umbrella when the forecast is above 70%
day sky forecast soaked yesterday rule says what happened
Mon grey 0.80 yes bring poured ok
Tue clear 0.75 no bring stayed dry wrong
Wed grey 0.60 yes leave it poured wrong
Thu clear 0.20 no leave it stayed dry ok

Two days out of four. The rule is not stupid. It is reading real evidence, and on Monday and Thursday it is right for the right reasons.

It fails because it reads one clue and treats that clue as the whole story, and because the cutoff, 70%, was picked by a person who guessed.

You can patch it. Add "or the sky is grey" and Wednesday comes right, and now Tuesday has two ways to be wrong instead of one. Add "unless you got soaked yesterday" and you are three rules deep, hand-tuning numbers you cannot justify, on four days of data. The rest of this page is the machine that does not need you to guess.

Step 02 - Before this page
Before this page - nothing required

Nothing. This is the first page of the module. The only arithmetic anywhere on it is multiplying and adding.

Step 03 - The stage

Two dials, two sliders, one number out. Drag anything. Nothing below this figure is needed to play with it, and nothing on this page will make sense faster than two minutes of dragging will.

The two inputs are set to Monday: the sky at 0.80, the forecast at 0.60. The third clue from the rule above, "got soaked yesterday", is folded into the number labelled bias, and the next page shows you exactly how that folding works and why it costs nothing.

Preview frame from the "What Is a Neural Network?" animation0:14

What this animation shows

Three small "clue" dots appear on the left and flow into a tiny network: a hidden layer of four neurons, then a single output neuron. A signal lights up layer by layer, left to right, until the output neuron turns green and a "Yes" appears next to it. This is the no-math mental model for the whole module: a neural network combines several clues and produces a decision.

0.6-0.30.730.62inputweighted sumoutput
x₁ × w₁ = 0.60 × 0.80 = 0.480
x₂ × w₂ = -0.30 × -0.50 = 0.150
sum + bias = 0.480 + 0.150 + 0.10 = 0.730
tanh(0.730) = 0.623
A single neuron combining two weighted inputs and a bias, then applying an activation function.
Step 04 - One question first

The two sliders labelled w are trust dials. Drag w₂ from +2.00 all the way down to -1.00, and leave the forecast itself sitting at 0.60 the whole time. Before you do it: what happens to the output number, and why?

Commit to a guess, then open this

It falls from 0.802 to 0.401, crossing 0.5 on the way, which is the machine changing its mind.

The forecast never moved. It sat at 0.60 for the entire drag. The only thing that changed is how much this machine trusts it, and at -1.00 the dial has gone past "I don't care" and into "a high forecast is evidence againstrain", which is wrong about weather and is exactly the kind of wrong an untrained machine starts out being.

That is the whole idea of the page in one drag: the evidence and the trust in the evidence are two separate numbers, and only the second one is the machine's to change.

Step 05 - Plain explanation

A neuron takes several clues, multiplies each one by a number saying how much that clue counts, adds the results together along with one standing adjustment that belongs to no clue, and puts the total through a fixed curve so the answer comes out readable. That is the whole machine. What makes it worth building is that nobody sets those multipliers by hand: they start as arbitrary numbers, the machine is asked for an answer, the answer is compared against what actually happened, and every multiplier is nudged in whichever direction would have made it less wrong. Do that a few thousand times and the numbers stop being arbitrary.

The recipe you keep adjusting

A curry is salt, chilli and time. The recipe is not "add these three things"; it is "add these three things in these proportions", and the proportions are the whole recipe. Doubling the chilli is a different dish; doubling the time is a different dish again. There is also a standing adjustment that has nothing to do with any ingredient, which is that your family likes everything a little milder than the book says, so you take a notch off before you start. You did not derive any of these numbers. You cooked it, it was wrong, you moved a number, you cooked it again. That loop is the only thing a network does that a rule cannot.

Where it breaks downa cook tastes the finished dish and adjusts by feel; a network is told, separately for every single number, which direction reduces the error and by how much.

Step 06 - The depth ladder
WordsWhat it is, before any numbersThe umbrella story, what the word neuron is not claiming, and the three kinds of layer by name.Rung 01

Before any code or math: imagine deciding whether to bring an umbrella. You glance at the sky, check the forecast, and remember if you got soaked yesterday. You don't weigh those three clues equally - the forecast probably matters more than your gut feeling about the clouds. You combine all three, weighted by how much you trust each one, and land on a decision.

A neural network automates exactly that process, using numbers instead of clouds and forecasts. Each clue becomes a number, each "how much it matters" becomes a weight, and the combined result becomes a decision. The one part a network can do that you can't: if it gets the decision wrong enough times, it automatically adjusts how much it trusts each clue - that adjustment process is what the rest of this page calls training.

Should I bring an umbrella?

Sky looks greymatters a lot
Forecast says 80% rainmatters most
Got soaked yesterdaymatters a little

combine the weighted cluesyes, bring it

Everything in this module is a variation on the paragraph you just read. Three clues, a number saying how much each one matters, and one combined answer. What changes from here is the level of detail, not the idea.

The name gives the wrong impression, so it is worth spending one sentence on. A "neuron" here is not a model of a brain cell. It is a single arithmetic step: multiply some numbers, add them up, apply one fixed curve to the total. The word is a historical borrowing from a 1943 paper that used brain cells as loose inspiration, and it stuck. Nothing on this site depends on the biology being accurate, and it isn't. Read "neuron" as "one small arithmetic unit" and you will never be misled.

The three layers, named

A network is these small arithmetic units arranged in layers, and there are only three kinds of layer to know.

The input layer is not really made of neurons at all. It is just your clues, sitting there as numbers. It computes nothing. If you have two clues, your input layer is two numbers wide.

The hidden layersare where the actual arithmetic happens. They are called hidden for an unglamorous reason: nobody outside the network ever looks at their values. You hand the network an input and read its answer, and everything in between is internal bookkeeping you never inspect unless you deliberately go looking. A network can have one hidden layer or a hundred. "Deep learning" just means "more than a couple".

The output layerproduces the answer you actually asked for. Its shape is decided entirely by the question. One number for "how many millimetres of rain". One number for "will it rain, yes or no". Three numbers for "dry, drizzle, or downpour".

Data moves in one direction through this, left to right, input to hidden to output. Running one input all the way through and reading the answer is called the forward pass, and it is the entire subject of the next two pages.

NumbersThe same decision, done with arithmeticOne neuron, three clues, every multiplication written out. The total comes to +1.40.Rung 02

Here is the umbrella decision above, done with actual numbers rather than clouds. Three clues, each scaled onto a 0-to-1 range, each with a weight saying how much it counts. Blue weights are positive, meaning "more of this clue pushes toward yes". Orange weights are negative, meaning "more of this clue pushes toward no". That colour convention holds on every diagram on this site and never changes.

WORKED EXAMPLE - one neuron, three clues
clue value weight contribution
sky looks grey 0.80 +1.50 (blue) 1.50 * 0.80 = 1.20
forecast chance of rain 0.60 +2.00 (blue) 2.00 * 0.60 = 1.20
got soaked yesterday 1.00 +0.30 (blue) 0.30 * 1.00 = 0.30
----------------
sum of contributions 2.70
bias -1.30
----------------
total 1.40

Read the three weights before reading the total. The forecast is trusted most, at +2.00. The sky is trusted next, at +1.50. Yesterday's soaking barely counts, at +0.30, which is the network's way of saying "that is weak evidence, but it is not nothing".

The biasof -1.30 is the one number not attached to any clue. It is the network's standing scepticism: start 1.30 in the hole, and let the evidence climb back out. Without it, a day with mild evidence everywhere would still come out positive, because every clue here counts towardrain and no clue's value can drop below zero, so the total could never be anything but positive. You would carry an umbrella every day of your life.

The total came out +1.40, comfortably above zero, so the evidence cleared the scepticism and the answer is "bring it".

A real network does not stop at "above zero or not". It passes that 1.40 through a curve that turns it into something readable, and the standard choice for a yes/no question gives 0.802184, which you can read as an 80.2% chance of rain. Which curve, why that one, and where 0.802184 comes from are the next three pages. The arithmetic above is the part that never changes.

One simplification, flagged rather than buried: the "above zero means yes" step is not what a real network does. Real networks use a smooth curve rather than a hard cutoff, for reasons the gradient pages make unavoidable. The arithmetic is the same either way; the cutoff is the part that gets replaced.

PictureThe same arithmetic, labelled on the diagramWhere the numbers actually come from, and a diagram with z and a marked on it.Rung 03

Where the numbers come from

A network only ever sees numbers. Everything you feed it has to be turned into numbers first, and that conversion is a real design decision, not a formality.

A measurement is easy. Temperature, price, age, pixel brightness: use the number, usually rescaled so it lands in a small range like 0 to 1 or -1 to 1. The rescaling matters more than it sounds like it should, and the initialization pages explain why.

A categoryhas no natural number. "Monday" is not 1 more than "Sunday". The standard fix is one-hot encoding: give each category its own input, set that one to 1 and all the others to 0. Seven days becomes seven inputs, exactly one of which is hot on any given day.

An image is already numbers. A 28x28 greyscale image is 784 brightness values, and the simplest thing you can do is line them all up as 784 inputs. That works, badly, and the reason it works badly is the entire motivation for convolutional networks.

Text is the hard case and is out of scope here.

Each individual input number is called a feature. The correct answer you are training toward is called the label or the target. A dataset is a pile of (features, label) pairs.

The same neuron at rest, with the two weighted edges, the bias, the pre-activation z and the activation a each labelled where they happen. An orange edge would mean a negative weight.

That diagram is the arithmetic above with names attached to positions. The two blue edges are the multiplications, the middle circle is where the adding finishes and the number there is called z, and the right-hand circle holds what comes out of the curve, which is called a. Those two letters are used for the rest of the module and are worth attaching to a picture once, here, before either is used in a sentence.

EquationWriting the same line downTwo lines of symbols, then the same two lines with this page's own numbers substituted in.Rung 04

Everything in rungs 2 and 3 is this, once, in symbols:

z = w1 * x1 + w2 * x2 + w3 * x3 + b
a = f(z)

and with this page's own numbers substituted in:

z = 1.50 * 0.80 + 2.00 * 0.60 + 0.30 * 1.00 + (-1.30)
= 1.200000 + 1.200000 + 0.300000 - 1.300000
= 1.400000
a = f(1.400000) = 0.802184

w is a weight, x is an input, b is the bias, z is the total before the curve, a is the answer after it, and f is whichever curve you chose. Five letters. They do not change for the rest of this module, and the next page introduces each of them properly rather than in a list.

General caseThe same thing at full size, and the loop that picks the numbersThe three shapes of question every problem here takes, and the four-step loop that is all training is.Rung 05

The example above had three inputs and one neuron. Nothing about it changes when there are seven hundred inputs and forty thousand neurons except how long the sum is, which is a machine's problem and not yours.

The three shapes of question

Nearly every problem in this module is one of three shapes, and the shape decides what the output layer looks like. It is worth knowing the names now, because the last two pages of this module are entirely about getting this right.

Regression. The answer is a quantity. How many millimetres of rain, what price, how many minutes. One output number, and it is allowed to be any size, positive or negative.

Binary classification. The answer is yes or no. Will it rain. Is this email spam. One output number, squeezed to sit between 0 and 1, read as a probability.

Multi-class classification. The answer is exactly one option out of several. Dry, drizzle, or downpour. Cat, dog, or bird. One output number per option, all of them squeezed so they are positive and add up to exactly 1, read as a probability spread across the options.

There is a fourth shape people trip over: multi-label, where more than one answer can be true at once. A photo can be outdoor and daytime and contain people. That is not multi-class, and using multi-class machinery for it produces confidently wrong answers. The output-activations page takes that apart properly.

What "learning" actually means

The weights above (+1.50, +2.00, +0.30, and the bias -1.30) were hand-picked to make the arithmetic readable. In a real network nobody picks them. They start as small random numbers and get corrected. Collectively they are called the network's parameters, and they are the only thing that changes during training. The structure stays fixed; the numbers move.

The loop has four steps and never gets more complicated than this:

  1. Forward pass. Push an input through and get an answer. That is the whole of the next two pages.
  2. Loss. Compare that answer to the correct answer and produce one number measuring how wrong it was. Bigger number, more wrong.
  3. Backward pass. Work out, for every single parameter, whether nudging it up or down would have made the loss smaller, and how strongly. That answer, a direction and a size, is called the gradient. The size matters as much as the direction and will do real work from page 4 onward: a large gradient means this parameter has a lot of influence on the loss and should move a lot, a gradient of zero means moving it would change nothing at all, so it does not move.
  4. Update. Nudge every parameter a small step in the direction that reduces the loss. The piece of machinery that decides how big that step is is called the optimizer, and it gets its own page. Repeat, thousands of times.

One full pass over all your training data is one epoch. Training is that loop; inference is step 1 on its own, once the parameters have stopped moving, which is what happens every time you actually use a trained model.

Nothing else in this module is a new idea. It is that loop, examined one part at a time.

A few words that come up a lot from here on:

Weight - a number saying how much one input mattersBias - a number that shifts the decision, independent of any inputActivation - squashes the result into a useful rangeLoss - a number measuring how wrong a prediction wasEpoch - one full pass of training over all the dataGradient - a slope, how much an output changes for a tiny change in inputCross-entropy - a loss function for classification that punishes confident wrongness sharplySoftmax - turns a set of raw scores into a probability distribution that sums to 1Logit - the raw number before it's squashed into a probabilityVanishing gradient - when repeated small derivative multiplications shrink the training signal to nearly zero in early layersSymmetry breaking - random initialization that keeps neurons in the same layer from becoming identical clones
Step 07 - Why this and not that

Why this and not that

Why not just write the rule by hand?

The break at the top of this page is the answer, and it gets worse than it looks. Four clues with three sensible cutoffs each is 81 hand-written cases, and real problems have hundreds of clues. The rule-writing approach does not scale badly, it stops.

Why not a decision tree, which also learns?

Trees do learn, and on a table of tidy columns they are frequently better than a network and easier to read. A network earns its place when the input is raw and huge and has structure in it, like a picture or a sound. Nothing on this site claims networks are the right tool for everything.

Is the neuron claim about brains real?

No, and rung 1 says so. The arithmetic here bears about the same relation to a brain cell that a paper aeroplane does to a heron. Nothing on this site depends on the biology, and the biology is not accurate.

If the weights start random, why does this ever work?

Because the correction in step 3 of the loop is not a guess. It computes, for every parameter separately, which direction reduces the loss and by how much. Random is only where it starts.

Why does the bias exist at all?

Without it, and with every clue's value at or above zero and every weight positive, the total can never be anything but positive, so the machine says "bring an umbrella" every day of its life. The bias is the only number that can push back against all the evidence at once.

Name origins
neuron
McCulloch and Pitts, 1943, who used brain cells as loose inspiration for a threshold-and-sum unit. The name stuck; the resemblance did not.
bias
borrowed from statistics, where it is the intercept of a fitted line. It has nothing at all to do with fairness bias, and the collision of the two meanings is a genuine hazard when reading around the subject.
weight
from "weighted average", which is exactly what step 1 and step 2 compute.
hidden
not secret. Nobody outside the network ever reads those values, so from the outside they are hidden the way a car's gearbox is hidden.
deep
more than a couple of hidden layers. There is no threshold; the word is marketing that became standard.
epoch
a period of time. One epoch is one full sweep over all your training data.
feature, label
a feature is one input number describing one thing; a label is the correct answer you are training toward. Both come from statistics and predate networks by decades.
training
rather than programming: you never write the numbers. You write the loop that finds them.
Step 08 - Where people go wrong
Step 09 - Practice
  1. 01
    Reproduce Monday. Set the sky to 0.80 with a weight of 1.50, the forecast to 0.60 with a weight of 2.00, the bias to -1.00, and the activation to Sigmoid. Read the total and the output.
    Hint
    The two contributions should both be 1.200.
    Answer

    Total 1.400, output 0.802. Both contributions are 1.200, so the raw evidence is 2.400 and the bias takes 1.000 of it back.

  2. 02
    Without touching any input or any weight, make the machine say no about Monday.
    Hint
    The evidence from the two inputs is fixed at 2.400. What has to be true of the bias for the total to fall below zero?
    Answer

    Any bias below -2.40. At exactly -2.40 the total is 0.000 and the output is 0.500, the fence. At -2.45 the total is -0.050 and the machine says no. The bias is how much evidence this machine demands before it will agree with you.

  3. 03
    Make the forecast completely irrelevant, and prove it.
    Hint
    One slider, one value.
    Answer

    Set w₂ = 0.00. Now drag the forecast across its whole range and the total does not move at all: it sits at 1.20 - 1.00 = 0.20, output 0.550. A weight of zero is the machine saying "I have no opinion about this clue", and it is what a weight that never mattered decays toward during training.

  4. 04
    Find a setting where a clear sky with a certain forecast says yes, and a grey sky with no forecast at all says no.
    Hint
    You are being asked to make one clue decisive and the other one mute.
    Answer

    One solution is w₁ = 0.00, w₂ = 2.00, bias = -1.00. Clear sky with a certain forecast, inputs (0.00, 1.00), gives a total of 1.000 and an output of 0.731. Grey sky with nothing forecast, inputs (1.00, 0.00), gives -1.000 and 0.269. Same machine, opposite verdicts, decided entirely by which clue it was told to trust.

  5. 05
    Hardest. Make the output come out at exactly 0.500, then say in one sentence what all such settings have in common.
    Hint
    Look at what the output does as the total passes through zero.
    Answer

    The output is exactly 0.500 whenever the total is exactly 0.000, and never otherwise. One example on Monday's inputs is bias -2.40. The reason is that sigmoid crosses 0.5 at exactly zero and only ever climbs, which means "the output is above half" and "the total is above zero" are the same statement about the same machine. The next page turns that fact into a line you can draw.

Step 10 - Seen in the wild
  • Your bank's fraud checkThis exact arithmetic with a few hundred more clues: the amount, the distance from your last purchase, the hour, the merchant category, each with a learned weight, summed into one number that either clears the payment or holds it.
  • Before the payment clearsIt runs before the payment completes rather than after because one forward pass is a few hundred multiplications and additions, which is microseconds, and the whole reason this shape of machine is everywhere is that it is that cheap to ask.
Step 11 - Memory anchor

A room of advisors, each with a volume knob, and one bored chairman who starts by saying no.

The knobs are the weights. The chairman is the bias. Training is turning the knobs until the room is right more often than it is wrong, and nobody in the room, including the chairman, knows anything about the weather.

Step 12 - The next break

One machine of this shape, however well its knobs are turned, can only ever split the world with one straight cut. Ask it to bring an umbrella when it is windy orcold but not when it is both, and there is no setting of any knob that gets all four cases right. Not "nobody has found one". None exists, and the proof is four lines long.

Before that proof is worth reading, this one machine has to be built properly, with every step named and every number checked by hand. That is the next page.

The Single Neuron