> For teachers > Middle School

Lesson plan · 5 days

Teaching a Network to Learn

A week-long unit that connects neural networks to the linear equations students are learning, and ends with networks that learn on their own. Every lesson on the middle school page is used, along with its three example networks.

Grade levels
Grades 6–8
Duration
Five class periods of 45 minutes, across one or two weeks
Class activities
5 activities, one a day, using 12 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.

  5. 05

    Training and testing

    Check a trained network against data it has never seen, to judge whether it really learned.

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.
  • Plotting points on a coordinate grid, for Day 2.
  • 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.

Positive and negative weights · 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 this week the class will open up a neural network, then watch one learn.

Pose a problem without a computer. "A zoo gets about 240 visitors for every hour of sunshine. How many on a day with 3 hours?" Write it on the board as 3 × 240 = 720, and explain that the 240 is the network's weight.

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 hours of sunshine.
Weight
The number on a connection. The input is multiplied by it.
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.

Make a table

Pairs make a table for each network, inputs in one column and outputs in the other, and describe the pattern in words: the zoo goes up by 240 each row, the mountain down by 6.

Post-activity discussion

  1. What does the sign of a weight tell you?

    Listen for Positive: the output goes up as the input goes up. Negative: it goes down.

  2. What would the mountain network say after 2.5 km?

    Listen for -15 degrees. The network can predict inputs it was never shown.

  3. What would a weight of 0 mean?

    Listen for The input makes no difference to the output.

The bias is the starting value · 45 minutes

Class Activity: Day 2

Introduction for students

Pose a problem: "A bus costs $2.00 to board and $0.75 for each mile. What does a 4-mile ride cost?" A weight alone can't do it, because the $2.00 is paid whatever the distance.

Introduce the bias, a number added after multiplying. Write the fare as 0.75 × 4 + 2 = 5, then as y = mx + b, then as a network writes it: weight × input + bias.

Key Vocabulary

Bias
A number added after multiplying, like the starting value b.
Slope
How much the output changes for each unit of input. In a network, the weight.
y-intercept
The output when the input is zero. In a network, the bias.

Guiding the activity

Predict the fares

Pairs open The Bus Fare Calculator 01, which only asks them to observe. The weight is 0.75 and the bias is 2. Partners predict each fare before stepping to it: $2.75, $3.50, $4.25, $5.00.

Graph the network

On a coordinate grid, pairs plot the four fares, miles on the x-axis and dollars on the y-axis, and draw the line through them. Ask them to mark where it crosses the y-axis ($2.00, the bias) and how much it rises for each mile ($0.75, the weight).

Design a fare

Each pair invents a fare of their own, a taxi or a bike rental, with a starting price and a price per mile. They write it as weight × input + bias, draw its line on the same grid, and compare it with the bus: which is cheaper for a short ride, and which for a long one?

Post-activity discussion

  1. Where on the graph do you see the weight, and where the bias?

    Listen for The weight is the steepness of the line; the bias is where it crosses the y-axis.

  2. What happens to the line if the bias goes up by $1?

    Listen for The whole line moves up by $1. Its steepness doesn't change.

  3. Where do two fares' lines cross, and what does that mean?

    Listen for At the distance where both cost the same. Shorter or longer rides favour one or the other.

Making a decision · 45 minutes

Class Activity: Day 3

Introduction for students

Ask: "What should a network predict for ice cream sales on a freezing day?" A weight and a bias 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. On a graph, the line runs along the x-axis until it reaches zero, then rises. 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.

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 them to sketch the frost warning's graph, flat at zero above 4 degrees and rising as it gets colder.

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 · 45 minutes

Class Activity: Day 4

Introduction for students

So far, the class has set every weight and bias by hand. Real AI has millions of them, so it has to find them by itself, and 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.
Positive error
The output is higher than the target: the network guessed too high.
Negative error
The output is lower than the target: the network guessed too low.

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.

Fix it by hand

Ask pairs to use the errors to choose a better weight for the bean plant, test it on paper against the four plants, and work out the new errors. Some will find that no single weight makes every error zero, because real plants don't grow exactly to a rule.

Add up the mistakes

Pairs compare their weights by adding up the size of each error, ignoring the sign. The smallest total wins: this is how a network judges which weight is best.

Post-activity discussion

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

    Listen for Down. Every output was too high.

  2. Why can't any weight make every bean plant error zero?

    Listen for Real data is messy. The best a network can do is make the errors small overall.

  3. Why ignore the sign when adding up the errors?

    Listen for Otherwise a too-high guess and a too-low guess would cancel out and look like no mistake at all.

A network that learns · 45 minutes

Class Activity: Day 5

Introduction for students

Yesterday the class used the errors to choose a better weight by hand. Today the network does it by itself: after every error, it nudges its weight in the direction that makes the next error smaller.

Write the idea on the board: a positive error pushes the weight down, a negative error pushes it up, and a bigger error pushes it further. Doing this over and over, across all the training data, is how AI learns.

Key Vocabulary

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.
Testing data
Inputs and targets the network never learned from, used to check whether it really learned.

Guiding the activity

Watch it learn

Open The Delivery Time Predictor 01 on the board. 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.

A bias that learns

Pairs open The Cookie Jar Predictor, which learns its bias as well as its weight. The bias, the cookies in a fresh jar, starts too low at 6 and climbs to about 9.6 over 16 jars. Ask pairs to record the bias every four jars.

Test what it learned

Pairs then explore The Tree Growth Predictor 02, an example that learns its weight from 1 to 1.27. After training, they switch to the testing data, heights the network has never seen, and check whether its predictions still hold.

For early finishers

The Recycling Sorter learns to tell glass from plastic using two inputs and two outputs. Pairs step through the training data, watch the two outputs separate, then try the testing data.

Post-activity discussion

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

  2. Why test a network on data it never trained on?

    Listen for A network could memorize its training data. Testing data shows whether it learned the pattern.

  3. What could go wrong if a network learned from bad data?

    Listen for It would learn the wrong pattern, just as confidently. Let this lead into a talk about where AI's training data comes from.

Wrap up

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 draw it, graph it, invent three targets that don't fit it exactly, calculate the errors, and say which way the weight and bias should be nudged.

Close the week by asking each student to finish the sentence "A neural network learns by…" on a sticky note. Strong answers mention calculating the error, output minus target, and nudging the weight and bias to make the next error smaller. Students can keep exploring at iinnoo.app, where every lesson is free and needs no account.

Ready to bring iiNNoo to your classroom?

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

Start Learning How AI Learns