Grades 6β8
How a Network Decides and Learns
For three days, we open up a neural network, find an equation you know inside it, and watch it learn.
Day 1
Weight Γ input + bias
Where did AI predict for you today?
Maps
Your arrival time.
Videos
The next video to watch.
Texting
The rest of your sentence.
Each of these comes from a neural network. Let's find out what is at its core.
Middle School Β· Grades 6β8
Ride the bus
A bus costs $2.00 to board and $0.75 for each mile. What does a 4-mile ride cost?
| fare = | 0.75 | Γ | 4 miles | + | 2 |
| y = | m | Γ | x | + | b |
| output = | weight | Γ | input | + | bias |
Middle School Β· Grades 6β8
Inside a neural network
Weight
Multiplies the input, like the slope m.
Bias
Added after multiplying, like the starting value b.
Target output
The real answer the output should match.
Middle School Β· Grades 6β8
Key vocabulary
- Neural network
- A kind of AI that makes predictions by passing numbers along connections, multiplying and adding them.
- Input value
- The number that goes into the network, such as the miles ridden.
- Weight
- The number on a connection. The input is multiplied by it, like the slope m.
- Bias
- A number added after multiplying, like the starting value b.
- Output value
- The number that comes out: the network's prediction.
- Target output
- The real answer. The output should match it.
Middle School Β· Grades 6β8
Activity
Change the weight
The network thinks each hour of sun brings 200 visitors. The targets say 240.
- Click the weight and change it.
- Step through all four inputs.
- When an output matches its target, the lines turn green.
Middle School Β· Grades 6β8
Activity
A negative weight
The air gets 6 degrees colder for every kilometer you climb, so the weight is -6.
| km climbed | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| change in degrees | ?-6 | ?-12 | ?-18 | ?-24 |
What weight would you use for something that gets warmer as you climb?
Middle School Β· Grades 6β8
Activity
Add a bias
Weight 0.75, bias 2. Predict each fare before you step to it.
| miles | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| fare | ?$2.75 | ?$3.50 | ?$4.25 | ?$5.00 |
What would a 0-mile ride cost? Why?
$2.00, the bias: the starting value.
Middle School Β· Grades 6β8
Done early?
Graph it
Plot the four bus fares on a grid and draw the line through them.
- What is the line's slope?
- Where does it cross the y-axis?
The slope is the weight. It crosses at the bias.
Middle School Β· Grades 6β8
Discussion
- Which part of the network is like the slope, and which is like the y-intercept?
- What does a negative weight tell you?
- How would you change the network if the bus cost $2.50 to board?
Middle School Β· Grades 6β8
Day 2
Making a decision
Nobody sells negative ice creams
On a freezing day, weight Γ input + bias can give a negative number of ice creams.
An activation function fixes that: after the weight and the bias, it turns any negative value into zero.
Now a network can make a decision: switch an output off until something is true.
Middle School Β· Grades 6β8
Key vocabulary
- Activation function
- A rule applied to a node's value. Here, it turns any negative value into zero.
- Node
- A circle in the network that holds a value. Each output is a node.
- Threshold
- The input where an output switches on, such as the temperature where sales begin.
Middle School Β· Grades 6β8
Activity
Hold it at zero
Weight 1, bias -60, and an activation function that turns any negative value into zero.
No one sells negative ice creams!
At what temperature do sales begin?
Middle School Β· Grades 6β8
Challenge
Set the frost warning
This time, you set both the weight and the bias. The warning should grow as it gets colder, and switch off when it's warm.
- As the temperature goes up, does the warning go up or down?
- So is the weight positive or negative?
- What bias makes the warning switch off at the right temperature?
Middle School Β· Grades 6β8
Test the edge
The frost warning: weight -1, bias 4.
Done early? Work out one message's spam ratings before you step to them.
The Spam Filter Sample Networks tab β Middle School Β· Grades 6β8
Discussion
- Why does the frost warning need a negative weight?
- What does the bias of 4 mean for the frost warning?
- Where else might a network need to switch something off?
Middle School Β· Grades 6β8
Day 3
Measuring the error, then learning
How wrong is the network?
Real AI has millions of weights, so it has to find them by itself. First, it measures how wrong it is.
Positive error
The network guessed too high.
Negative error
The network guessed too low.
Middle School Β· Grades 6β8
Key vocabulary
- Error
- The output value minus the target value: how far off the prediction is, and which way.
- Weight update
- Changing a weight after an error, so the next error is smaller.
- Learning
- Updating the weights and bias, over and over, until the errors are small.
- Training data
- The inputs and targets the network learns from.
Middle School Β· Grades 6β8
Activity
Read the error
The network guesses 3 cm a day. Watch the error for each plant.
| plant | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| error | ?1 | ?3 | ?2 | ?4 |
Every error is positive. What does that say about the weight?
Middle School Β· Grades 6β8
Activity
Predict the error
The weight is 3 tickets a coin. Predict each error before the network works it out.
| round | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| error | ?4 | ?3 | ?2 | ?6 |
Take turns: one predicts, the other checks.
Middle School Β· Grades 6β8
Together
Watch it learn
This network updates its own weight after every error. It starts at 0.5 minutes a kilometer.
Record the weight after every delivery. Where does it settle?
Middle School Β· Grades 6β8
Done early?
A bias that learns
The Cookie Jar Predictor learns its bias as well as its weight. The bias is the cookies in a fresh jar.
Record the bias every four jars. Which way is it heading?
Middle School Β· Grades 6β8
Discussion
- If the error is positive, should the weight go up or down?
- Why did the delivery weight never land exactly on 3?
- How is what the network did like what you did on Day 2?
Middle School Β· Grades 6β8
Your own network
Write a network for something in your life with a weight and a bias, like a phone plan with a monthly fee and a cost per gigabyte.
- Give it one input and work out the output.
- Invent a target.
- Calculate the error.
What is inside a neural network?
Middle School Β· Grades 6β8