> For teachers > Middle School

Lesson plan · 3 days

How a Network Decides and Learns

Three days that take a network from an equation to a learner: weights and bias, then activation functions that make a decision, then error and the first network that fixes itself. Each day starts with a short whole-class introduction and ends with a discussion.

Grade levels
Grades 6–8
Duration
Three class periods of 45 minutes
Class activities
3 activities, one a day, using 10 iiNNoo lessons

Learning objectives

Students will be able to:

  1. 01

    Weight × input + bias

    Model a real situation with a weight and a bias, and connect them to the slope and starting value of a linear equation, y = mx + b.

  2. 02

    Making a decision

    Use negative weights and an activation function to show how a network decides, such as when to warn gardeners about frost.

  3. 03

    Measuring the error

    Calculate error as the output value minus the target value, and explain what a positive or a negative error means.

  4. 04

    Learning from mistakes

    Observe a network learning, as it nudges its weight and bias after every error to make the next error smaller.

Prerequisite knowledge

Before starting, students should be comfortable with:

  • Multiplying and adding with negative numbers, such as -1 × 6 + 4.
  • Multiplying a decimal by a whole number, such as 0.75 × 4.
  • Seeing a rule like "$2 to start plus $0.75 a mile" as a starting amount plus a rate, or as y = mx + b.
  • Clicking, and typing a number, on a computer or tablet. Students can share one device between two.

Weight × input + bias · 45 minutes

Class Activity: Day 1

Introduction for students

Ask the class where AI has made a prediction for them today: a map's arrival time, a recommended video, a phone finishing a sentence. Explain that for three days the class will open up a neural network and find out that it is built from an equation they already know, and that it can learn.

Pose a problem without a computer. "A bus costs $2.00 to board and $0.75 for each mile. What does a 4-mile ride cost?" Write the answer on the board as 0.75 × 4 + 2 = 5, then as y = mx + b, then as a network writes it: weight × input + bias.

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 of the network: its prediction.
Target output
The real answer. The network's output should match it.

Guiding the activity

Change the weight

Open The Zoo Visitors Predictor 02 on the board, label its input value, weight and output value, then hand it to pairs. The weight starts at 200 and the targets need 240. When an output matches its target, the double lines between them turn green.

A negative weight

Pairs open The Mountain Climb Calculator, which only asks them to observe. The air gets 6 degrees colder for every kilometer climbed, so the weight is -6, and every output is negative: -6, -12, -18, -24. Ask what the weight would be for something that gets warmer as you climb.

Add a bias

Then The Bus Fare Calculator 01, with a weight of 0.75 and a bias of 2. Partners predict each fare before stepping to it: $2.75, $3.50, $4.25, $5.00. Ask what a 0-mile ride would cost, and why the answer is the bias.

Graph it

Pairs who finish plot the four fares on a grid and draw the line through them. The line's slope is the weight and it crosses the y-axis at the bias.

Post-activity discussion

  1. Which part of the network is like the slope, and which is like the y-intercept?

    Listen for The weight is the slope; the bias is the output when the input is zero.

  2. What does a negative weight tell you?

    Listen for That the output goes down as the input goes up.

  3. How would you change the network if the bus cost $2.50 to board?

    Listen for Only the bias, to 2.5. The weight, the cost per mile, stays the same.

Making a decision · 45 minutes

Class Activity: Day 2

Introduction for students

Ask: "What should a network predict for ice cream sales on a freezing day?" The equation from Day 1 can give a negative number, and nobody sells negative ice creams.

Introduce the activation function: after the weight and the bias, the node turns any negative value into zero. That lets a network make a decision, switching an output off until something is true.

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.

Guiding the activity

Watch it hold at zero

Pairs open The Ice Cream Sales Predictor, which only asks them to observe. Its weight is 1 and its bias is -60. At 70 degrees the node works out 10 ice creams; at 50 it works out -10, and the activation function turns that into 0. Ask students to find the threshold where sales begin (60 degrees).

Set the frost warning

The Frost Warning Detector asks students to set both the weight and the bias. Coach with questions: "As it gets warmer, does the warning go up or down? So is the weight positive or negative?" The answer is a weight of -1 and a bias of 4, a warning that starts at 4 degrees and grows as it gets colder.

Test the edge

Ask pairs to check the 6-degree day by hand: -1 × 6 + 4 = -2, which the activation function holds at zero. Then ask what the warning would be at -5 degrees (9).

For early finishers

The Spam Filter is an example with three inputs and two outputs, and no task to finish. Links and shouted words push a message towards spam, polite words towards safe. Ask pairs to work out one message's ratings before stepping to them.

Post-activity discussion

  1. Why does the frost warning need a negative weight?

    Listen for Because the warning goes up as the temperature goes down.

  2. What does the bias of 4 mean for the frost warning?

    Listen for It sets the threshold: the warning is zero until the temperature drops below 4 degrees.

  3. Where else might a network need to switch something off?

    Listen for Alarms, warnings, anything that cannot be negative: a spam filter, a smoke detector, money left over.

Measuring the error, then learning · 45 minutes

Class Activity: Day 3

Introduction for students

Recall that on Days 1 and 2, the class set every weight and bias by hand. Real AI has millions of them, so it has to find them by itself. The first step is to measure how wrong it is.

Write the rule on the board: error = output value − target value. A positive error means the network guessed too high; a negative error means too low. Try one together: the network says 15, the target is 11, so the error is 4.

Key Vocabulary

Error
The output value minus the target value: how far off the prediction is, and in which direction.
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.

Guiding the activity

Read the error

Pairs open The Bean Plant Predictor, which only asks them to observe. The network guesses 3 cm a day, which overshoots every plant, so every error is positive: 1, 3, 2, 4. Ask what that says about the weight: it is too big.

Predict the error

The Arcade Ticket Predictor asks students to predict each error before it is calculated. The weight is 3 tickets a coin, too high again, and the errors are 4, 3, 2 and 6. Partners take turns: one predicts, the other checks.

Watch it learn

Bring the class back together and open The Delivery Time Predictor 01 on the board. This network updates its own weight after every error. It starts at 0.5 minutes a kilometer; the first delivery's error is -5.4, far too low, and the weight jumps to 2.66. Step through all 8 deliveries and record the weight each time on the board: it settles near 3, the real minutes a kilometer.

For early finishers

The Cookie Jar Predictor learns a bias as well as a weight. The bias, the cookies in a fresh jar, starts at 6 and climbs to about 9.6 over 16 jars.

Post-activity discussion

  1. If the error is positive, should the weight go up or down?

    Listen for Down. The output was too high, so the network makes it smaller.

  2. Why did the delivery weight never land exactly on 3?

    Listen for Traffic makes every delivery a little different, so each error pushes the weight a little. It settles near the answer that fits them all best.

  3. How is what the network did like what you did on Day 2?

    Listen for Both looked at how far off the output was and adjusted. The network does it with arithmetic, on every example, without being told the answer.

Wrap up

On a half sheet of paper, each student writes a network for something in their own life with a weight and a bias, such as a phone plan with a monthly fee and a cost per gigabyte. They give it one input, work out the output, then invent a target and calculate the error.

Close the unit by returning to the first day's question: what is inside a neural network? Students should now be able to answer weight × input + bias, an activation function to make decisions, and an error that tells the network which way to adjust.

Ready to bring iiNNoo to your classroom?

Questions or ideas? Email us at support@iinnoo.app.

Start Learning How AI Learns