> For teachers > High School

Lesson plan · 5 days

Building a Network That Learns

A week-long unit on the full algorithm behind modern AI, from the forward pass to gradient descent, ending on a network that predicts the next word in a sentence. Every lesson on the high school page is used, along with its three example networks.

Grade levels
Grades 9–12
Duration
Five class periods of 45 to 50 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

    Hidden layers

    Trace a forward pass through hidden layers, with weighted sums, biases and an activation function, and predict each middle node's value before the network works it out.

  2. 02

    Back propagation

    Follow the error back across each weight, see it add up at a node that feeds several outputs, and see it stop at a node the activation function held at zero.

  3. 03

    Gradient descent

    Apply the update rule, input value × error × learning rate, and explain why a learning rate that is too large makes training overshoot or blow up.

  4. 04

    Training vs. testing

    Use testing data the network has never seen to judge whether it has truly learned, and compare how well it learned each of its outputs.

  5. 05

    From networks to language models

    Explain how a network that predicts the next word is built from the same steps, and what its training data decides.

Prerequisite knowledge

Before starting, students should be comfortable with:

  • Evaluating an expression such as 2 × 1 + 3 × 2 with the order of operations.
  • Multiplying with negative numbers and decimals, such as 2 × -3 × 0.02.
  • Knowing that a function turns an input into an output. No calculus is needed, though students who know a little will see where it fits on Day 3.
  • Clicking, and typing a number, on a computer or tablet. Students can share one device between two.

Through the hidden layer · 45–50 minutes

Class Activity: Day 1

Introduction for students

Ask the class which AI tools they have used this week, and how they think those tools got so good. Every one was trained with three steps, repeated billions of times: a forward pass, back propagation and a weight update. By Friday, the class will have done all three by hand.

Today is the forward pass. Each node works out a weighted sum, each input times its weight, added together, then adds its bias and applies an activation function. The nodes in the middle are a hidden layer: their values are never in the data, only worked out on the way.

Key Vocabulary

Hidden layer
A layer of nodes between the inputs and the outputs. Its values are worked out, never given.
Weighted sum
Each value coming into a node times its connection's weight, added together.
Bias
A number added to a node's weighted sum.
Activation function
A function applied to a node's value. Here, ReLU: any negative value becomes zero.
Forward pass
Working out every node's value, layer by layer, from the inputs to the outputs.

Guiding the activity

Predict the middle nodes

Pairs open The Talent Show Predictor, which asks them to predict each middle node and the output in the first round. With 2 acts and 3 posters, the top middle node is 2 × 1 + 3 × 2 = 8 and the bottom one 2 × 2 + 3 × 1 = 7. The output is 8 × 5 + 7 × 10 = 110.

A bias and an activation

The Birthday Book Predictor has one middle node with a bias of -10, the $10 owed to a friend, and an activation function. Students predict the first two rounds. $5 gives 5 - 10 = -5, held at 0, and so 0 books. $30 gives 20 dollars left, and 20 × 0.2 = 4 books.

Read a bigger network

Pairs then explore The Traffic Light Decider, an example with three inputs, four middle nodes and three outputs, and no task to finish. Each road has its own path through a middle node. Ask them to click on connections to find that path, and to explain what the 0.8 weights mean: 0.8 of green time for each car waiting.

Post-activity discussion

  1. Why does the network need a middle layer at all?

    Listen for Middle nodes can combine the inputs in different ways, and the activation function lets each one switch on only when it is useful. Without them, the network could only draw a straight line.

  2. What did the activation function do in the Birthday Book Predictor?

    Listen for It stopped the network predicting negative books when there was not enough money to pay back the friend.

  3. If a network gives the wrong answer, which numbers would you change?

    Listen for The weights and biases, the only numbers that aren't inputs or worked out from them. That is the rest of the week.

Sending the error back · 45–50 minutes

Class Activity: Day 2

Introduction for students

Recall the forward pass in one sentence from a student. Today the network gets an answer wrong, and the class follows how it works out who is to blame.

The error is the output value minus the target value. Back propagation sends it back across each weight: a middle node receives the output's error times the weight connecting them. A node that feeds several outputs adds up what comes back from each.

Key Vocabulary

Error
The output value minus the target value.
Back propagation
Sending the error back across each weight, so every node knows its share of the mistake.
Middle error
The error a middle node receives: each output's error times the weight between them, added up.

Guiding the activity

Where the error stops

Pairs open The Street Musician Predictor, which asks them to predict the error that reaches the middle node. In round 1 the network predicts $20 against $23: an error of -3, which reaches the middle node as -3 × 0.5 = -1.5. The input values receive nothing, because nothing can change them.

Errors that add up

The City Park Predictor has two outputs, wrappers and bottles, so each middle node collects two errors. Students predict both middle nodes in the first two rounds: -399 and -199, then 399 and 199. The weights start hidden, and each prediction shows the ones it needs.

Show the working

Ask pairs to write each middle error as a sum of products on paper before typing it, such as -3 × 0.5. It makes the City Park Predictor much easier to check.

Draw it

Pairs who finish draw the City Park network on paper and label every connection with the error that travels back along it in round 1, then check their labels against the app.

Post-activity discussion

  1. Why does the error travel back across the weights?

    Listen for A weight decides how much a middle node contributed to the output, so it decides how much of the error that node is responsible for.

  2. Why do the input values never receive an error?

    Listen for They are the data. Nothing the network does can change them.

  3. A City Park middle node got a large error from one output and a small one from the other. Which matters more?

    Listen for They are simply added. The larger one dominates, and their signs can cancel out.

Where the error stops · 45–50 minutes

Class Activity: Day 3

Introduction for students

Yesterday the error reached every middle node. Today it doesn't. A middle node that the activation function held at zero played no part in the output, so no error reaches it.

Explain why: changing a weight into that node wouldn't change the output, because the node would still be held at zero. For students who know some calculus, the activation function's slope is zero there, and the error is multiplied by that slope.

Key Vocabulary

ReLU
The activation function used here: a negative value becomes zero, and a positive one passes through unchanged.
Inactive node
A node that the activation function holds at zero. It receives no error.
Slope
How much a function's output changes for a small change in its input. ReLU's slope is 0 below zero and 1 above it.

Guiding the activity

One node at a time

Pairs open The Yawn Predictor. Its middle nodes measure the hours of sleep over and the hours short, so at most one is above zero a round, and only that one receives an error. Students predict 4 and 0 in round 1 (10 hours slept, 8 needed), then 0 and 3 in round 2 (7 slept, 11 needed).

A node that never wakes

The Pet Rescue Predictor has three middle nodes, and the bottom one's bias of -20 is more than any day's dogs and cats can make up, so it is held at zero every day. Students predict the top and bottom middle errors in the first two rounds: -3.5 and 0, then 3.5 and 0.

Find the reason

Ask pairs to write one sentence for each zero they predicted, saying why that node received no error. The best answers name the activation function, not just the number.

For early finishers

Ask pairs what would have to change for the pet rescue's bottom node to ever receive an error: a smaller bias, or many more animals in a day.

Post-activity discussion

  1. Why did one yawn node receive no error in each round?

    Listen for The activation function held it at zero, so changing its weights would not have changed the output.

  2. The pet rescue's bottom node never receives an error. What does that mean for its weights?

    Listen for They will never change. The node is dead, a real problem in large networks, and one reason the starting weights and biases matter.

  3. Why is it useful that only the active nodes get an error?

    Listen for Each one only learns from the examples it took part in, so different middle nodes can specialize in different situations, like over-sleeping and under-sleeping.

Gradient descent · 45–50 minutes

Class Activity: Day 4

Introduction for students

Every connection now knows its share of the error. Today the network uses it to change its weights, the step that makes it learn.

Write the update rule on the board: adjustment = input value × error × learning rate, and the new weight is the old one minus the adjustment. The input value is what came into the connection, the error is the one that reached the node it leads to, and the learning rate keeps each step small. Moving every weight a small step against its error is gradient descent.

Key Vocabulary

Weight update
Subtracting input value × error × learning rate from a weight.
Learning rate
A small number that sets how big each weight update is.
Gradient descent
Training by moving every weight a small step in the direction that makes the error smaller.
Overshoot
Stepping past the best weight, so the error grows instead of shrinking.

Guiding the activity

One update by hand

Pairs open The Recycling Drive Predictor, which asks for the output error, both middle errors and one weight's adjustment in round 1. 2 classes predicts 3 bags against 6: an error of -3, reaching the middle nodes as -3 and -1.5. The adjustment to the top middle node's weight is 2 × -3 × 0.02 = -0.12, which raises it from 1 to 1.12.

Watch it settle

Pairs keep stepping through the 8 drives and note the output error each time. It shrinks to within about 1 bag by the end, and stays there, because the number of bags is never exactly 3 a class.

Find the learning rate

The Test Score Predictor 02 learns at a rate of 0.2, and its weights blow up. Pairs try every other rate and record what each one does in a table. The one that works is 0.02.

Sketch the error

Ask pairs to sketch the error against the weight as a valley, and draw each learning rate as steps down it: tiny steps that never reach the bottom, steps that land there, and steps that jump across and climb the other side.

Post-activity discussion

  1. Why multiply by the input value in the update rule?

    Listen for A connection whose input was large had a large effect on the output, so it takes a large share of the fix. One whose input was zero had no effect and doesn't change.

  2. What happens when the learning rate is too large? Too small?

    Listen for Too large and each step overshoots, further each time, until it blows up. Too small and it learns so slowly it never gets there.

  3. Why is it called gradient descent?

    Listen for The gradient is the slope of the error. Each update takes a step downhill, against the slope, towards the bottom of the valley.

Training, testing and the next word · 45–50 minutes

Class Activity: Day 5

Introduction for students

This week the class has done every step of training by hand. Today the networks do thousands of steps at once, in swift mode, and the class judges them the way AI researchers do: on testing data they have never seen.

Explain why: a network can fit its training data without learning the pattern behind it, the way a student can memorize answers without understanding them. That is called overfitting, and testing data is how it is caught.

Key Vocabulary

Training data
The examples a network learns from.
Testing data
Examples the network never learned from, used to check whether it really learned.
Overfitting
Fitting the training data so closely that the network does worse on new data.
Swift mode
Running the network's steps quickly, without showing each calculation.
Language model
A network that predicts the next word from the words before it, the kind of AI that writes text.

Guiding the activity

Train, then test

Pairs open The Harbor Predictor, which learns swimmers and sailboats from sunshine and wind through a middle layer. They train it across all the training days, then switch to the testing data and decide which of its two answers it learned better: the sailboats, off by about 0.7 a testing day against about 1.1 for the swimmers.

A deeper network

The Air Quality Monitor is an example with two hidden layers and 255 steps a round. Pairs train it in swift mode, then switch to the testing data to confirm it learned correctly.

Predict the next word

Bring the class together for The Next Word Predictor, a tiny language model that learns from 7 short sentences such as "the dog is cute" and "the sky is blue". Train it in swift mode, switch to the testing data, and ask the class which words it expects after "is": cute, big, blue and hot, the words that followed "is" in its training sentences.

Post-activity discussion

  1. Why did the Harbor Predictor learn the sailboats better than the swimmers?

    Listen for Let students reason from the data: whichever answer follows the inputs more consistently is easier to learn.

  2. The Next Word Predictor only knows 10 words. What would change for a real language model?

    Listen for Vastly more words, layers and weights, and training on a huge amount of text. The forward pass, back propagation and gradient descent stay the same.

  3. The Next Word Predictor only says what it saw in training. What does that mean for real AI?

    Listen for A model learns whatever is in its training data, including mistakes and biases. Let this lead into a talk about who chooses that data.

Wrap up

Each student draws a small network of their own on paper, two inputs, two middle nodes and one output, for something from their own life. They choose its weights, run one forward pass, invent a target, and carry it through back propagation and one weight update at a learning rate of 0.1.

Close the week by asking each student to explain, in a short paragraph, how an AI model learns. Strong answers name the forward pass, the error, back propagation and gradient descent, and say why the model is tested on data it never trained on. 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