Lessons › Chapter 8: Neural networks
The perceptron
A perceptron is the simplest artificial neuron. It takes a few inputs, here three yes/no facts about a concert, and produces one decision: go or stay home.
Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.
Start the interactive lessonStep by step
One brain cell
Leo starts learning neural networks from the smallest piece: a single artificial neuron.
One artificial neuron
A perceptron is the simplest artificial neuron. It takes a few inputs, here three yes/no facts about a concert, and produces one decision: go or stay home.
Weigh each input
Each connection has a weight: how much that input matters. Here a friend going matters most (0.9), the ticket price least (0.2). Thicker lines mean bigger weights.
Add up, then decide
Multiply each input by its weight and add them up: 0.6 + 0.9 + 0 = 1.5. That’s above the threshold of 0.5, so the output is 1: go to the concert.
Learning means adjusting weights
If the neuron decides wrong, its weights are nudged so the decision would have been better. Repeat over many examples and it learns which inputs really matter. Every big neural network is made of millions of these.
In real life: should your phone buzz?
Lots of simple product decisions are one weighted sum. Should this notification buzz your phone right now? Weigh how important it is, whether you’re in a meeting, and the time of day, then compare against a threshold.
Quick check: What does a perceptron compute before making its decision?
- A weighted sum of its inputs (correct)
- The average of all outputs
- A random number
It multiplies each input by its weight, adds them up (plus a bias), then compares to a threshold.
Pseudocode
inputs = [weather_is_good, friend_is_going, ticket_is_cheap]
weights = [0.6, 0.9, 0.2]
total = sum(input × weight) + bias
if total > 0.5:
output 1 # go to the concert
else:
output 0 # stay home
Key terms
- perceptron
- The simplest artificial neuron: a weighted sum followed by a yes/no threshold.
- neuron
- A tiny unit that adds up its weighted inputs and passes the result through an activation.
- weight
- A number on a connection that says how much one input matters. Learning means adjusting weights.