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?

0.75 Γ— 4 + 2 = ?$5.00
fare =0.75Γ—4 miles+2
y =mΓ—x+b
output =weightΓ—input+bias

Middle School Β· Grades 6–8

Inside a neural network

0.75 4 miles 5 dollarsbias 2 5 target

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 Zoo Visitors Predictor 02 Forward Propagation tab β†—

The network thinks each hour of sun brings 200 visitors. The targets say 240.

  1. Click the weight and change it.
  2. Step through all four inputs.
  3. When an output matches its target, the lines turn green.

Middle School Β· Grades 6–8

Activity

A negative weight

The Mountain Climb Calculator Forward Propagation tab β†—

The air gets 6 degrees colder for every kilometer you climb, so the weight is -6.

km climbed1234
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

The Bus Fare Calculator 01 Forward Propagation tab β†—

Weight 0.75, bias 2. Predict each fare before you step to it.

miles1234
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.

  1. What is the line's slope?
  2. Where does it cross the y-axis?

The slope is the weight. It crosses at the bias.

Middle School Β· Grades 6–8

Discussion

  1. Which part of the network is like the slope, and which is like the y-intercept?
  2. What does a negative weight tell you?
  3. 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

The Ice Cream Sales Predictor Forward Propagation tab β†—

Weight 1, bias -60, and an activation function that turns any negative value into zero.

70 degrees: 1 Γ— 70 - 60 = 10 ice creams
50 degrees: 1 Γ— 50 - 60 = ?-10 β†’ 0

No one sells negative ice creams!

At what temperature do sales begin?

Middle School Β· Grades 6–8

Challenge

Set the frost warning

The Frost Warning Detector Forward Propagation tab β†—

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.

  1. As the temperature goes up, does the warning go up or down?
  2. So is the weight positive or negative?
  3. 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.

6 degrees: -1 Γ— 6 + 4 = ?-2 β†’ 0
-5 degrees: -1 Γ— -5 + 4 = ?9

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

  1. Why does the frost warning need a negative weight?
  2. What does the bias of 4 mean for the frost warning?
  3. 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.

error = output value - target value
+

Positive error

The network guessed too high.

βˆ’

Negative error

The network guessed too low.

The network says 15. The target is 11. Error: ?4

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 Bean Plant Predictor Back Propagation tab β†—

The network guesses 3 cm a day. Watch the error for each plant.

plant1234
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 Arcade Ticket Predictor Back Propagation tab β†—

The weight is 3 tickets a coin. Predict each error before the network works it out.

round1234
error?4?3?2?6

Take turns: one predicts, the other checks.

Middle School Β· Grades 6–8

Together

Watch it learn

The Delivery Time Predictor 01 Weight & Bias Update tab β†—

This network updates its own weight after every error. It starts at 0.5 minutes a kilometer.

first delivery's error: ?-5.4
new weight: ?2.66
after all 8 deliveries: ?about 3

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 Weight & Bias Update tab β†—

The Cookie Jar Predictor learns its bias as well as its weight. The bias is the cookies in a fresh jar.

bias at the start: 6
bias after 16 jars: ?about 9.6

Record the bias every four jars. Which way is it heading?

Middle School Β· Grades 6–8

Discussion

  1. If the error is positive, should the weight go up or down?
  2. Why did the delivery weight never land exactly on 3?
  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.

  1. Give it one input and work out the output.
  2. Invent a target.
  3. Calculate the error.

What is inside a neural network?

Middle School Β· Grades 6–8