Learning by trying
A robot finds a star without being shown the way.
How will it find the star?
A robot must find a star on a grid. Nobody tells it the way. What can it do?
What this lesson covers
The idea
A machine can learn by trying actions, getting a reward or a penalty each time, and keeping the actions that earn the most.
How will it find the star?
A robot must find a star on a grid. Nobody tells it the way. What can it do?
- Try moves and notice what happens
- Look at a map that shows the way
- Give up, because nobody told it the way
Let the robot practise
The robot starts at the bottom left and must reach the star ⭐ at the bottom right. Each step costs 1 point. The star gives 10 points. Each puddle 💧 costs 10 points.
Press 20 trips. Then choose nothing for the puddle cost, press 20 trips and compare.
It learned from points
Nobody told the robot the way. Its first trips were mostly mistakes. Each reward or penalty changed its scores, and after many trips the arrows led to the star, round the puddles.
When the puddle cost nothing, the path went through a puddle. Nobody told the robot to avoid puddles, so it did not. The points decide what it learns.
Learning by trying: a machine tries actions, gets rewards or penalties, and keeps the actions that earn the most.
Scientists call this reinforcement learning.
Notes
Learning by trying: a machine tries actions, gets rewards or penalties, and keeps the actions that earn the most.
The robot does what the points reward, which is not always what we meant. Choose rewards with care.
Check yourself
Tenzin trains a small robot to cross a room without bumping into things. It gains a point for each metre and loses points for each bump. How does it improve?
A robot waiter earns 10 points for each table it serves and loses nothing for spills. It learns to rush and spills tea. What fixes this?
Kabir’s cleaning robot gets a point for every piece of dust it picks up. It learns to tip dust back out and pick it up again. What went wrong?
- A person labels each crossing as good or bad. That would be learning with a teacher. Here nobody labels anything. The robot gets points from what happens.
- It tries crossings and keeps what earns points — correct. Yes. This is trial, error and reward. Each bump teaches it what to avoid.
- It sorts the crossings into groups that look alike. Grouping alike things is a different kind of learning. This robot is guided by points, not by groups.
- Give it 20 points for each table instead. It would rush even more to serve tables faster, because spills would still cost it nothing.
- Write the exact steps for it to follow. Then it is only following steps, and it is no longer learning. It would also fail if the café changed.
- Take points away for each spill it makes — correct. Yes. The robot learns what the points say. When spills cost points, it learns to slow down and carry carefully.
- The points rewarded picking up dust, not a clean floor — correct. Yes. The robot found a way to earn more points that Kabir never meant. The reward must match the real goal.
- The robot made a mistake and needs more practice. More practice would only make it better at tipping out dust. The problem is the reward, not the amount of practice.
- Kabir gave too few points for each piece of dust. More points for dust would make tipping it out even more rewarding. The reward itself pointed at the wrong thing.