How does a machine make a decision?
AI learns patterns from data. Its smallest building block is the artificial neuron: a little calculation that takes in information and makes one decision. Ours decides whether a classroom light should switch on.
Tap each part of the neuron
0 of 7 exploredStart exploring
Tap any part of the diagram, or a button below it. The text changes with the Beginner, Intermediate and Advanced switch at the top.
Biological neuron vs artificial neuron
Inspired by, not a copy| Biological neuron | Artificial neuron | What it does |
|---|---|---|
| Dendrites | Inputs x₁, x₂, x₃ | Receive signals |
| Synapse strength | Weights w | Make some signals count more than others |
| Cell body | Summation Σ + bias | Combines the signals |
| Firing threshold | Activation function | Decides whether to send a signal on |
| Axon | Output | Passes the result on |
An artificial neuron is a maths idea inspired by brain cells. It isn't a tiny brain cell. Real neurons use chemistry and electricity and are far more complicated. Artificial neurons are mathematical models inspired by biological neurons, not replicas. A real neuron fires electrical spikes over time and changes through chemistry. An artificial neuron just multiplies, adds and applies a function. The artificial neuron (McCulloch and Pitts, 1943; Rosenblatt's perceptron, 1958) is a deliberately simple abstraction. Biological neurons show spiking dynamics, dendritic computation and neurochemical plasticity that this weighted-sum-plus-nonlinearity model doesn't capture.
Can your AI decide when a smart classroom light should turn on?
Three sensors feed your neuron. You choose how much each one matters. Watch every number change as you move a slider.
Controls
ACTIVATION FUNCTION
Live calculation panel
Input × weight → weighted signalPredict first, then test
0 of 3 testedScientists predict before they change anything. Choose what you think will happen, then test it on your neuron.
Why did the bulb turn on (or stay off)?
What happens when a weight becomes negative?
A negative weight turns that input into a "switch it OFF" signal. The more of that input, the more it pushes the light towards off.
x × w becomes negative, so that input lowers z. An input with a negative weight works against switching on. Try it: give presence a negative weight, and people walking in makes the light less likely to turn on.
The sign of wi sets the direction of ∂z/∂xi = wi. A negative weight means increasing xi moves z (and any monotonic activation) down. Weights encode both importance (|w|) and direction (sign).
Why do we need bias?
Bias sets how easily the light switches on. A big negative bias means "only switch on if you're really sure". A positive bias means "switch on easily".
Without a bias, when every input is 0, z is always 0. Bias lets the neuron move its switching point, the threshold, without changing how much each input matters.
With a step activation, the neuron outputs 1 when w·x + b ≥ 0, a hyperplane. The bias offsets that hyperplane from the origin. Without it, every decision boundary would have to pass through x = 0, which badly limits what the neuron can represent.
How does a neuron turn z into a decision?
The activation function takes the net input z and transforms it into the output. Try all three, then change the sliders and watch the dot move along the curve.
Your neuron
Same z, three functions
z = 0Can your neuron learn from its mistakes?
Instead of setting the weights by hand, let the neuron learn them from examples. This is supervised learning with the perceptron rule.
Weights right now
What just happened
Step 1: receive inputsPress Train 1 example to watch a single learning step.
Training examples
Prediction uses the current weightsAccuracy after each pass
Mistakes in each pass
How the perceptron learns
- 1. Receive a training example's inputs x.
- 2. Predict: z = w·x + b, then step(z) gives 0 or 1.
- 3. Compare the prediction with the expected output (the target).
- 4. Error = target − prediction, which is −1, 0 or +1.
- 5. Update: wnew = wold + η × error × x and bnew = bold + η × error.
- 6. Repeat through all the examples, pass after pass, until a whole pass has no mistakes.
One neuron can only learn patterns where a single straight line can split the ON examples from the OFF examples. Try the staircase switches data: it never gets them all right. Module 6 shows how a network solves it. A single perceptron can only learn linearly separable patterns, where one straight line (or flat plane) separates the classes. The staircase switches (light on when exactly one switch is up) aren't separable, so training never reaches 100%. The perceptron convergence theorem guarantees finitely many updates if the data is linearly separable. The staircase data is XOR, which isn't, so the weights cycle forever (Minsky and Papert, 1969). Multilayer networks with non-linear hidden units overcome this.
Learning-rate experiment
Trains four fresh neurons on the classroom data from the same starting guess, with different learning rates. The results are real training runs.
| Press "Run the comparison". |
Can a neuron learn from its mistakes?
Yes. Every time it gets an example wrong, it nudges its weights in the direction that would have helped. When it's right, it changes nothing.
Yes. The error tells it which way to move. If it said OFF but should have said ON (error +1), every weight attached to an active input goes up. Correct answers give error 0, so nothing changes.
Yes. The perceptron rule is error-driven: Δw = η(t − ŷ)x. Updates happen only on misclassified examples and move the decision boundary towards classifying that example correctly.
What happens when the learning rate is too high?
The neuron takes giant steps. It overshoots, flips its mind back and forth, and can take longer to settle. Too small, and it learns very slowly.
Each update is η × error × input, so a large η makes big jumps that can overshoot the right answer. Run the comparison: very small and very large rates often need more passes than a middle value.
For a step-activation perceptron, scaling η is equivalent to scaling the initial weights by 1/η. So the rate matters only relative to where you start. For gradient-trained networks (sigmoid, ReLU), too large an η makes the loss oscillate or diverge, and too small slows convergence.
Break your neuron on purpose
Real AI engineers learn a lot from mistakes. Make your neuron fail, then investigate why. Every result is calculated from your neuron's actual weights.
Sabotage missions
Each mission changes your neuron. Watch the confusion matrix.Your neuron
The inputs come from each test room, so only the weights and bias are here. Decisions use your activation setting, where ON means z ≥ 0.
Confusion matrix
0%TP True positive: light ON, and it should be ON.
TN True negative: light OFF, and it should be OFF.
FP False positive: light ON when it should be OFF, so energy is wasted.
FN False negative: light OFF when it should be ON, so students sit in the dark.
Test rooms
Tap a row to investigateInvestigate a decision
Tap a room above to see which inputs pushed the decision, and why it was right or wrong.
What can many neurons do together?
Three inputs feed three hidden neurons, which feed one output neuron. Every number below is calculated live by forward propagation. Tap any connection or neuron to change it.
Inputs
Inspector
Tap a connection or a neuron in the diagram to adjust its weight or bias.
Show the mathematics
Turn on "Show calculations" to see every multiplication and addition in the forward pass.
Test on the data
0%Layers, connections and forward propagation
Input layer: the sensor readings. Hidden layer: three neurons that each spot a small clue. Output layer: one neuron that combines the clues into the final decision. Information flows forwards, layer by layer. That's forward propagation.
Each connection has its own weight, and each hidden or output neuron has its own bias. A hidden neuron computes z = Σ w·x + b, then a = sigmoid(z). The output neuron does the same with the hidden activations as its inputs. Doing this left to right is forward propagation.
With hidden weights W(1) (3×3), biases b(1), output weights w(2) and bias b(2): h = σ(W(1)x + b(1)), ŷ = σ(w(2)·h + b(2)). The non-linear σ in the hidden layer is essential. Without it, the whole network would collapse into a single linear neuron.
Why does a neural network need multiple layers?
Each hidden neuron spots one simple clue. The output neuron combines the clues. Together they can follow rules that are too tricky for one neuron, like the staircase switches.
One neuron draws one straight boundary. Hidden neurons each draw a boundary, and the output neuron combines them into shapes that aren't straight. Load the staircase preset: one hidden neuron acts like OR, another like AND, and the output says "OR but not AND".
Hidden layers compose non-linear features. By the universal approximation theorem, one sufficiently wide hidden layer with a non-linear activation can approximate any continuous function on a compact domain. Depth often gives more efficient representations.
Can a single neuron solve every problem?
No. If you can't split the ON and OFF examples with one straight line, a single neuron will always get some wrong. You saw this with the staircase switches in Module 4.
No. A single perceptron only solves linearly separable problems. The staircase switches (XOR) need at least one hidden layer. Compare Module 4, where training never reached 100%, with this network, which gets all four right.
No. A single threshold unit realises only linear threshold functions. Of the 16 Boolean functions of two inputs, XOR and XNOR aren't linearly separable. Adding one hidden layer makes them representable.
Neural network challenges
Seven challenges, from warm-up to expert. Each is worth up to 20 points. Hints cost 5 points, and each wrong check costs 2.
AI dashboard
Everything your neuron and your training run are doing, live.
Live neuron
stepNet input and output
Weight distribution
Bars: your neuron. White marks: the trained neuron from Module 4.
Input → output map
presence ↑
Brightness shows the output for every darkness and presence, with energy saving fixed at 0.7. Rings are the training rooms (gold = should be ON). The white cross is your current room.
Training accuracy
no training yetTraining loss
mistakes per passFor a step-function perceptron, the natural "loss" is the number of misclassified examples.