Learning objectives
Students will be able to:
-
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.
-
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.
-
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.
-
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.
-
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.
-
The Talent Show Predictor
This network predicts the audience at a school talent show. The input values are the number of acts and posters put up. Each input value reaches both middle nodes, and both middle nodes reach the output value. In the first round, predict each middle node value, then the output value. Enter your answer when asked.
Open lesson -
The Birthday Book Predictor
On your birthday, you get money that you can use to buy books. The input value is the dollars and the output value is the books. You owe your friend $10, so the middle node's bias is -10. Each book costs $5. Predict the middle node, then the output value, in the first two rounds. The activation function holds anything below zero at zero.
Open lesson -
The Traffic Light Decider
This network decides how long each of 3 roads gets a green light. The input values are the cars waiting on the north, east and south roads. The output values are the 3 green light times. Each road has its own path through a middle node. Click on a connection to see its weight.
Open lesson
Post-activity discussion
-
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.
-
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.
-
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.
-
The Street Musician Predictor
This network predicts what a street musician collects. The input values are the hours played in the morning and in the evening. The output value is the money in the hat. The input values never receive an error, because nothing can change them. Predict the error that reaches the middle node, where it stops.
Open lesson -
The City Park Predictor
This network predicts the litter left in a city park. The input values are the food trucks and snack carts. The output values are the wrappers and bottles left behind. Each middle node collects the errors from both output values. Predict the error that reaches each middle node in the first two rounds.
Open lesson
Post-activity discussion
-
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.
-
Why do the input values never receive an error?
Listen for They are the data. Nothing the network does can change them.
-
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.
-
The Yawn Predictor
This network predicts a student's yawns in class. The input values are the hours slept and the hours needed. Too much sleep or too little brings yawns. At most one middle node is above zero each round, and only that one can receive an error. Predict the error that reaches each middle node in the first two rounds.
Open lesson -
The Pet Rescue Predictor
This network predicts a day at a pet rescue. The input values are the dogs and the cats waiting for homes. The output values are the visitors and the adoptions. The bottom middle node's bias holds it at zero every day. Predict the error that reaches the top and bottom middle nodes in the first two rounds.
Open lesson
Post-activity discussion
-
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.
-
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.
-
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.
-
The Recycling Drive Predictor
This network predicts the bags of cans a school recycling drive collects. The input value is the number of classes taking part. The output error comes back to both middle nodes. In round 1, predict the output error, both middle errors, and the adjustment to the weight to the top middle node. The learning rate is 0.02.
Open lesson -
The Test Score Predictor 02
This network predicts a test score. The input values are the hours of study and of sleep. The output value is the score. Its weights blow up as it learns. Find a learning rate that keeps them under control. Figure out which learning rate works, then run it again.
Open lesson
Post-activity discussion
-
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.
-
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.
-
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.
-
The Harbor Predictor
This network learns how busy a harbor will be, through a middle layer. The input values are the sunshine and the wind, from 0 to 5. The output values are the swimmers and sailboats. Decide which of the two answers it learns better. Train it on all the days, then switch to testing data and compare.
Open lesson -
The Air Quality Monitor
This network turns 4 roadside readings into 4 pollutant levels. The input values are the traffic, wind, temperature and humidity, each scored from 0 to 5. The output values are the dust, nitrogen, ozone and carbon. With 255 steps a round, try swift mode with this one. Train it, then switch to testing data to confirm it learned correctly.
Open lesson -
The Next Word Predictor
This network predicts the next word in a sentence, like a tiny version of the AI that writes text. The input value is a word, and the output values show which word comes next. It learns from 7 short sentences, such as “the dog is cute” and “the sky is blue.” Train it in swift mode, then switch to testing data. Which words does it expect after “is”?
Open lesson
Post-activity discussion
-
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.
-
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.
-
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