Practice and reinforce the concepts from Lesson 2
Time: 30-40 minutes
Go to this link: https://studio.code.org/s/aiml-2021/lessons/1/levels/1
Click the Continue with Google button and sign in using your Google account.
Complete Lesson 1 to understand the concept of Machine Learning.
Complete Lesson 2 to understand how machines identify and recognize patterns.
:bulb: Take notes on key concepts like "training data," "patterns," and "predictions" - you'll use these ideas in the advanced challenge!
Part 2: Explore Simple Machine Learning Technology :art:
Time: 20-25 minutes
Watch this video to learn more about the website 'Quick, Draw!' (5 minutes)
Go and play the game 'Quick, Draw!' at this link. Play at least 3 rounds! (10 minutes)
Analyze the technology, algorithm, dataset used in building the game. Consider:
- How does the AI recognize your drawings?
- What happens when your drawing is unclear?
- How might the AI improve over time? tip Notice how the AI gives you multiple guesses - this shows the confidence levels of different predictions!
Time: 60-90 minutes
:information_source: Important This is a hands-on project where you'll train your own AI model! Make sure you have:
- A working microphone
- A quiet environment for recording
- Google Chrome or Firefox browser
In this part, you need to use MachineLearningforKids to train a Sound Recognition model. Unlike humans, computers do not recognize our everyday language such as English. In this project, we will let the computer recognize and differentiate the words "left" and "right" commands.
Go to website: https://machinelearningforkids.co.uk/
Select the option Try it now.
:bulb: No account needed! The "Try it now" option lets you start immediately without registration.
- Create a new project named Sound Recognition:
- Click on the "Projects" tab or "Go to your Projects" button:
- Click "Add New Project"
- Type in your Project Name, the name of this Project "Sound Recognition" and choose to recognize sounds. After that, click "create".
- The project has been created. Click into the project folder:
Phase One: Prepare Data :emoji:
Time: 15-20 minutes
After that, the next step is to create the dataset:
Click the "Train" button to start collecting examples
Click the "Add Example" button in the background noise bucket:
Click on microphone to record 2 seconds of background noise:
After finished recording, click on the Add button:
The background noise will then be added into the background noise category as shown below:
Repeat until you have 8 sets of background noise:
:bulb: Tip Record different types of background noise - silence, room noise, slight movements. This helps the AI distinguish between actual commands and ambient sounds!
Click on Add new label and add the label for left. This label directs the computer to move left.
Click Add example:
Record at least 8 examples of you saying left.
:bulb: Tip Vary your tone slightly between recordings - say it normally, loudly, softly, quickly. This makes your model more robust!
Repeat step g to i for another label named right.
By the end of step 4, your train data should look like this:
Click < Back to Project at the top left corner.
Phase 2: Model Training :emoji:
Time: 5-10 minutes
Click on the button Learn & Test
Click on "Train new machine learning model"
Wait for the model to finish training.
:information_source: Info
Training usually takes 1-3 minutes. The system is analyzing all your recordings to find patterns that distinguish "left" from "right" from background noise.
- After finished training, your project should look like this:
Phase 3: Model Testing :white_check_mark:
Time: 10-15 minutes
Click on the "Start listening" button to start recording your voice, it will then attempt to recognize what you say as either "left" or "right" and how confident it is at its reply.
If you do not like how your model is performing, you can always go back to provide more training data and retrain your model. tip Troubleshooting If your model isn't working well:
- Add more training examples (aim for 15-20 per category)
- Make sure your "left" and "right" recordings sound distinctly different
- Check that background noise examples don't contain any speech
If you are satisfied with the performance of your model, you can go back to your project page and click on "Make" and create a project based on this model we built using SCRATCH.
Click on the button "Scratch 3" to create a scratch project.
Click on button "Open in Scratch 3"
A new scratch project will be opened up. Your model will be represented as a new extension in the left tab.
Drag the code block "when green flag clicked" onto the sprite. This block can be found in the events section.
Drag "train new machine learning model" from the section "Sound Recognition".
Drag "wait until" block from the controls section
Drag "is the machine learning model" and "start listening" block as shown below:
Drag "when I hear left" and "when I hear right" from the section Sound Recognition as shown below:
From the section "motion", drag two "move steps" block as shown below. Change the value 0 in the blocks to -50 and 50 respectively:
Your final code for the sprite to look like this:
Now its time to test the model, click on the Green Flag to start the program.
Use your mic, give instructions as either "left" or "right" and you can watch how it moves to left or right. Note that it may take some time to respond as the model needs some time to be trained.
Feel free to customize the project in any way you want, you can:
:bulb: Creative Ideas
- Create a voice-controlled game where the sprite collects objects
- Add obstacles that the sprite must avoid
- Keep score based on successful voice commands
Microphone not working?
Model predictions are inaccurate?
Scratch project won't load?
:warning: Important Submission Instructions Before submitting, make sure you have:
- :white_check_mark: Completed all three parts of the exercise
- :white_check_mark: Successfully trained your sound recognition model
- :white_check_mark: Created and tested your Scratch project
- :white_check_mark: Taken screenshots of your working model (optional but recommended)
Please submit your work through this link: Exercise Submission Form
Submission deadline: Check with your instructor