> For teachers > Middle School

Lesson plan · 1 day

The Equation Inside an AI

A single class that finds y = mx + b inside a neural network. Students change a weight, watch a bias add a starting value, see an activation function hold a value at zero, then set a weight and a bias themselves.

Grade levels
Grades 6–8
Duration
One class period of 45 to 60 minutes
Class activities
1 activity, using 4 iiNNoo lessons

Learning objectives

Students will be able to:

  1. 01

    Weight × input + bias

    Calculate a node's output as the weight times the input plus the bias, and connect the weight to slope and the bias to the starting value.

  2. 02

    Negative weights

    Explain why a weight is negative when the output goes down as the input goes up.

  3. 03

    Making a decision

    Describe how an activation function holds any negative value at zero, so a network can switch something off.

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. Students who know y = mx + b will see it at once; those who don't will meet it here.
  • Clicking, and typing a number, on a computer or tablet. Students can share one device between two.

Finding y = mx + b · 45–60 minutes

Class Activity

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. Each comes from a neural network, and today the class will find out that the core of one is an equation they already know.

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?" Students will get $5.00. Write it on the board as 0.75 × 4 + 2 = 5, and then as y = mx + b. Explain that a network writes the same thing as weight × input + bias.

Open The Zoo Visitors Predictor 02 on the board and name its parts: the input value on the left, the connection's weight, and the output value on the right. Beside each output is its target output, the real answer the network should match.

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.
Activation function
A rule applied to a node's value. Here, it turns any negative value into zero.

Guiding the activity

Change the weight

Pairs open The Zoo Visitors Predictor 02. The network thinks each hour of sunshine brings 200 visitors, but the targets say 240. Students click the weight, change it to 240, and step through all four inputs. When an output matches its target, the double lines between them turn green.

Add a bias

Next, The Bus Fare Calculator 01, which only asks students to observe. The weight is 0.75 and the bias is 2. Before each step, ask partners to predict the fare: $2.75, $3.50, $4.25, $5.00. Point out that the bias is added to every fare, the way b moves every point of a line up by the same amount.

Hold it at zero

The Ice Cream Sales Predictor has a weight of 1 and a bias of -60, and an activation function. At 70 degrees the node works out 70 - 60 = 10 ice creams. At 50 degrees it works out -10, and the activation function turns that into 0: no one sells negative ice creams. Ask students to find the temperature where sales begin (60 degrees).

Set the frost warning

Last, The Frost Warning Detector asks students to set both the weight and the bias. The warning grows as it gets colder, so coach with questions: "As the temperature goes up, 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. At 6 degrees the node works out -2, and the activation function holds it at zero.

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: how much the output changes for each unit of input. The bias is the starting value, the output when the input is zero.

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

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

  3. What would the frost warning say at 6 degrees without its activation function?

    Listen for -2, which means nothing for a warning. The activation function lets the network switch the warning off.

  4. You set every weight and bias today. How could a computer find them on its own?

    Listen for By comparing its outputs with the targets, measuring how far off it is, and nudging each number to make that error smaller, over and over. That is how AI learns.

Wrap up

Finish with a two-question exit ticket. First: "A node has a weight of 3 and a bias of -5. What is its output for an input of 4?" (7). Second: "What is its output for an input of 1, with an activation function that turns negatives into zero?" (3 - 5 = -2, so 0).

Close by connecting back to the start: the networks behind a map or a chatbot are made of millions of these same weight × input + bias calculations, each followed by an activation function. 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