Lesson 3: Neural Networks
45 minutes
Overview
This lesson centers around the How AI Works: Neural Networks video from the How AI Works video series. Watch this video first before exploring the lesson plan.
Students learn how neural networks work. They first discuss an example of an experience that recommends things to you. They then use a widget that recommends videos based on one person. Students watch a video explaining neural networks. They use an updated widget to adjust the weights of each person. Finally, students discuss the need for diverse perspectives when creating recommendation systems.
This lesson can be taught on its own, or as part of a 7-lesson sequence on How AI Works - click here to view all lessons in this sequence.
Standards
AP - Algorithms & Programming
- 3B-AP-08 - Describe how artificial intelligence drives many software and physical systems.
- 3B-AP-11 - Evaluate algorithms in terms of their efficiency, correctness, and clarity.
CS - Computing Systems
- 3A-CS-01 - Explain how abstractions hide the underlying implementation details of computing systems embedded in everyday objects.
DA - Data & Analysis
- 2-DA-08 - Collect data using computational tools and transform the data to make it more useful and reliable.
- 2-DA-09 - Refine computational models based on the data they have generated.
- 3B-DA-05 - Use data analysis tools and techniques to identify patterns in data representing complex systems.
- 3B-DA-07 - Evaluate the ability of models and simulations to test and support the refinement of hypotheses.
IC - Impacts of Computing
- 2-IC-20 - Compare tradeoffs associated with computing technologies that affect people's everyday activities and career options.
- 3A-IC-24 - Evaluate the ways computing impacts personal, ethical, social, economic, and cultural practices.
- 3B-IC-26 - Evaluate the impact of equity, access, and influence on the distribution of computing resources in a global society.
Agenda
Objectives
Students will be able to:
- Explain the need for diverse perspectives when creating recommendation systems
- Use the weights of an artificial neuron to adjust the outputs of a recommendation system
Preparation
- Print copies of the WeTube Content Creators resource for each student
- Print copies of the Neural Network activity guide for each student
Links
Heads Up! Please make a copy of any documents you plan to share with students.
For the teachers
- Neural Networks - Slides
For the students
- How AI Works: How Neural Networks Work - Video
- Neural Networks - Activity Guide
- WeTube Content Creators - Resource
Teaching Guide
Before the Lesson
Getting Started with Code.org: Consider watching our Getting Started with Code.org video series for an overview of how to navigate lesson plans, setup a classroom section, and other important features of the Code.org platform. Each video also has a support article if you'd prefer to read or print instructions - click here to learn more.
Setup a Classroom Section: You can use a class section in Code.org to manage your students, view their progress, and assign specific curriculum - click here to learn more.
If you are using a learning management system, there may be additional steps to sync your classes with Code.org:
- Click here for steps to setup your classes with Google Classroom
- Click Here for steps to setup your classes with Clever
Become a Verified Teacher: Lesson plans and levels have additional resources and answer keys for Verified Teachers, which is quick process that verifies your position at an educational institution. Click here to complete a form and you should have access to verified teacher resources in ~1 business day.
Supports for Teachers: You can learn more about bringing AI lessons to your classroom through our AI 101 for Teachers series. AI 101 for Teachers is a free, foundational online professional learning series for any teacher and educator interested in the groundbreaking world of artificial intelligence (AI) and its transformative potential in education.
Warm Up (5 minutes)
Recommendations
Prompt: Think of a time when you got a recommendation (for a video, a food, etc.) from either another person or a website or an app. Think of 1-2 examples to share.
Discussion Goal: Encourage students to think of things that make recommendations, especially different apps or websites. For example, they may be recommended videos from Youtube or new songs on a music app. Some apps may ask you to pick preferences before using them to help figure out your preferences. Some websites give recommendations at the end of an experience, like a takeout menu or online grocery store recommending new items before checking out. Try to crowdsource a variety of examples before continuing to the next prompt
Prompt: Do these recommendations tend to be accurate? Or do they feel random?
Discussion Goal: Responses here will vary, and there's no expected answer. Instead, focus on the tension between getting recommendations that are accurate and how not every recommendation may feel like it matches each student's interests and personality.
Remarks
We get recommended things all the time, but how do these programs know what to recommend? How do they get better? Today we're going to look at one way computers create recommendations using something called neural networks.
Neural Networks (35 minutes)
WeTube (Beta)
Distribute: Pass out the WeTube Content Creators resource.
Display: Display the slide with information about WeTube, which is also on the top of the handout.
Model: Show students the widget and demonstrate how to select a person and then view the video recommendations.
Real Or Fake? Students may have lots of questions about this business model and why it's a good idea to only go by recommendations. These may be valid questions if this were a real business, but it's not - assure students that this is just an excuse to focus on the role of recommendations in our world. However, it is true that the underlying concepts in this business and how recommendations work are similar to real-world recommendation systems, even if the company is fake.
Real-World Recommendation Systems: Spotify is one of many companies that uses a similar interface when users first use the app - it asks users to pick 4-5 different artists, and then curates songs based on those preferences.
The new Threads app from Meta is another example of a social media recommendation algorithm that works similarly to this program. In Threads, your feed is curated entirely by who you follow - there's no ability to search for phrases or further customize the feed yourself. Similarly, in this app, your feed is entirely determined by which artist you follow.
Widget | Say |
---|---|
![]() |
|
Code Studio: Send students to the first level in Code Studio. As they work, have them consider the following prompt
Prompt: Which content creator resonates with you the most and are most excited to follow? Which one resonates with you the least?
Circulate: Walk around as students experiment with the app. Make sure they understand the interface - that after choosing a content creator, they see a list of video recommendations they can explore. Encourage students to explore different content creators and see what videos are recommended. Students should notice that the videos seem to match the personalities of each person with some variation. Once most students have looked at a few content creators, regroup the class.
Regroup: Have students regroup to discuss the following prompt
Prompt: Ask the following questions in quick succession and having students respond non-verbally (for example, by raising their hands). The goal is to quickly move through these questions to motivate the next section of the lesson.
- Were there any videos that showed up for your person that you didn't think were super interesting or disagreed with?
- Were there any videos that showed up for another person that you wish had shown up with your favorite person?
Remarks
It’s super unlikely that just subscribing to 1 person will give you the ideal recommendations - there may be some things here that you actually don’t like, and you’d rather do something that a different user recommended instead. There’s gotta be a way to combine these different perspectives to fine-tune the recommendations that we get. Let’s look at how computer science and artificial intelligence can help with that!
Video: Show the How AI Works: How Neural Networks Work
Videos are used throughout the curriculum to spark discussions, supplement key concepts with additional explanations and examples, and expose students to the various roles and backgrounds of individuals in computer science.
While interacting with the video, turn on closed captioning so students can also read along as they watch.
To encourage active engagement and reflection, use one or more of the strategies discussed in the Guide to Curriculum Videos.
WeTube 2.0
Display: Show the "WeTube Version 2.0" slide, which describes the updates to the widget. Click through the next slides to explain the differences in the widget.
Slide | Say |
---|---|
![]() | Display and Say: You can now combine recommendations from each person. |
![]() | Display and Say: You can use the slider to adjust how much this person will influence your recommendations. Just like in the video, we're adding more weight to their recommendation |
![]() | Display and Say: You can click on someone else and combine their recommendations. The thicker the line, the more they influence the recommendations. |
![]() | Display and Say: Here are some of the recommendations we get with Sofia and Joseph. Both of their preferences are reflected here. |
![]() | Display and Say: You can also click the Select New Weights button to go back and change your preferences. For example, we could decide to add Alex to our recommendation model. |
![]() | Display and Say: When we do that, some new videos appear in our feed that were influenced by Alex's preferences. |
Distribute: Pass out the Neural Networks Activity Guide. Read through the overview at the top of the handout.
Code Studio: Have students go to the next level in Code Studio.
Do This:
- Use the widget to create a custom recommendation system using each of the content creators.
- Combine their weights until you get a series of recommendations that you like and agree with.
- Test multiple combinations before settling on one that you like
How Is It Learning? This widget is similar to the example shown in the video and, behind the scenes, each person has given a rating to the different "videos" that get recommended. However, there is a key difference: in the video, the network customizes the weights by "learning" from how users rate the videos that are recommended to them, but in this widget users can manually adjust the weights to customize the network themselves. In this sense, the widget isn't really "learning" in the same way the video learns. However, it does create an equivalent type of recommendation system, and is similar to other recommendation systems that let users customize their interests themselves.
Circulate: Monitor students as they complete this task. Students should be testing different combinations of weights and recommendations. Encourage students to share observations with their neighbors and really play with the combinations. Some probing questions could be:
- Are there any videos that appear for certain people?
- If you pick a particular video, is there a way to get it to the "front page" of your recommendations in your top 3?
- Are there videos that never seem to make it to the top 3?
Regroup: As students begin to settle on combinations that they like, regroup the class
Do This: Jenna is a student who loves Boba Tea. There's a video called "Boba Tea Hacks: Unique flavor combinations". She's trying to find a combination that gets this video to the Top 3 videos. Can you help her?
Circulate: Give students a few minutes to experiment here combining different content creators to get the video to appear in the top 3. Transparently: this video is designed to always be rated low by the current selection of content creators and never appear in the Top 3, so students won't actually be able to accomplish this task. This is intentional and designed to motivate the final part of the activity.
Remarks
It seemed like it was nearly impossible for Jenna to see her interest represented in her Top 3. Thinking about how Jenna must feel, it can be pretty disappointing to not be able to see your own interests represented in an app like this.
Prompt: Have there been times where your interests or perspectives haven't been represented in an app? Why do you think that is?
Have students share with their neighbors
Discussion Goal: Students may have a wide variety of experiences here. Some may be comical or inconsequential, like not having their favorite type of food recommended to them no matter how hard they try. Others may be more influential and consequential, like never having music or books or movies reflective of their identities or culture recommended back to them. Focus the discussion on why this might be, emphasizing answers that focus on the diversity of the data used for the recommendation algorithm. When this comes up, feel free to transition to the next part of the activity.
Reflecting on Social Media: Depending on student engagement in this discussion, this may be an opportunity to reflect on the impact of algorithmic recommendations and student participation in social media. Studies have shown that social media can negatively impact teen mental health (ie: seeing ads or recommendations that promote a negative self-image), and some students may describe themselves as addicted to social media.
Depending on your comfort with these topics, you could decide to facilitate a discussion with students. If so, consider using Make Peace with Social Media as a resource for both you and your students.
Remarks
Recommendation systems are only as good as the data they have to work with. In this example, none of our content creators liked the Boba Tea video enough to make it rise to the top, even though people like Jenna clearly want to watch it. Sometimes this causes people to leave the app entirely, but there's also another solution: adding more perspectives to the data!
Do This: Flip the activity guide to the back side and read the overview as a class:
Remarks
You are now in charge of imagining a new content creator that WeTube will add to their recommendation system. This person could be based on an existing person (even yourself!), or could be totally imaginary. The key thing is that this person should represent new interests and perspectives not represented by the current group of people.
Do This: Design your own content creator on the activity guide
Circulate: Check in with students as they complete this task, encouraging them to consider perspectives that aren't represented with the current group of content creators. This is also an opportunity to check in with and encourage students who may have been especially excited about the content of seeing themselves represented in a system like this, or may have felt their interests or culture historically excluded from existing recommendation systems.
Real-World Connections: Consider sharing with students the work of Michael Running Wolf, an Indigenous computer scientist who is working to add Native languages like Salish, Cheyenne, or Blackfoot to voice assistants. Part of this work includes creating the data that the assistants can use when generating their response, since that data was missing when these systems were first created. Consider sharing this news article with students or completing one of the activities from the CS Education Week CS Heroes series
Wrap Up (5 minutes)
Prompt: Why is it important to have a diverse set of data when creating a recommendation system?
Discussion Goal: This prompt is an opportunity to review and synthesize the last part of today's activity, where students contemplated how recommendation systems are dependent on the data used to create them. Encourage students to make connections between this prompt and some of the recommendation systems they brought up in the warm-up, considering how an expansive set of data can help make sure the system works for everyone instead of just a specific subset of people.
After the Lesson
Teacher Survey
We'd love to learn more about the folks teaching these lessons and the classroom experience. Please let us know in this How AI Works Teacher Survey.
Additional Lessons
If you'd like to teach additional lessons from the How AI Works video series, click here to explore additional resources
AI and Machine Learning Unit
If you'd like to dive even deeper into AI and Machine Learning, consider exploring our 5-week unit on AI and Machine Learning. Click here to view the unit and learn more
This work is available under a Creative Commons License (CC BY-NC-SA 4.0).
If you are interested in licensing Code.org materials for commercial purposes contact us.