10.11 Continuous State Spaces | Lunar lander  -[Machine Learning | Andrew Ng]
 The lunar lander lets you land a simulated vehicle on the moon. It's like a fun little video game that's been used by a lot of reinforcement learning researchers. Let's take a look at what it is. In this application, you're in command of a lunar lander that is rapidly approaching the surface of the moon, and your job is to fire thrusters at the appropriate times to land it safely on a landing pad. To give you a sense of what it looks like, this is the lunar lander landing successfully, and it's firing thrusters downward and to the left and right to position itself to land between these two yellow flags. Or if the reinforcement learning algorithms policy does not do well, then this is what it might look like where the lander unfortunately has crashed on the surface of the moon. In this application, you have four possible actions on every time step. You could either do nothing, in which case the forces of inertia and gravity pull you toward the surface of the moon, or you can fire a left thruster. When you see a little red dot come out on the left that's firing the left thruster, they'll tend to push the lunar lander to the right, or you can fire the main engine that's thrusting down the bottom here, or you can fire the right thruster, and that's firing the right thruster which will push you to the left. And your job is to keep on picking actions over time so as to land the lunar lander safely between these two flags here on the landing pad. In order to give the actions a shorter name, I'm sometimes going to call the actions nothing, meaning do nothing, or left, meaning fire the left thruster, or main, meaning fire the main engine downward, or right. So I'm going to call the actions nothing, left, main, and right for short later in this video. How about the state space of this MTP? The states are this position x and y, so how far to the left or right and how high up is it, as well as velocity x dot y dot. How fast is it moving in the horizontal and vertical directions? And then also, is angle, so how far is the lunar lander tilted to the left or tilted to the right? Is angular velocity theta dot? And then finally, because a small difference in positioning makes a big difference in whether or not it's landed, we're going to have two other variables in the state vector, which we'll call L and R, which corresponds to whether the left leg is grounded, meaning whether or not the left leg is sitting on the ground, as well as R, which corresponds to whether or not the right leg is sitting on the ground. So whereas x, y, x dot y dot theta, theta dot are numbers, L and R will be binary valued and can take on only values 0 or 1, depending on whether the left and right legs are touching the ground. Finally, here's the reward function for the lunar lander. If it manages to get to the landing pad, then it receives a reward between 100 and 140, depending on how well it's flown and gotten to the center of the landing pad. We also give it an additional reward for moving toward or away from the pad. So if it moves closer to the pad, it receives a positive reward. If it moves away and drifts away, it receives a negative reward. If it crashes, it gets a large negative 100 reward. If it achieves a soft landing, that is a landing that's not a crash, it gets a plus 100 reward. For each leg, the left leg or the right leg that gets grounded, it receives a plus 10 reward. And then finally, to encourage it not to waste too much fuel and fire thrusters unnecessarily, every time it fires the main engine, we give it a negative 0.3 reward. And every time it fires the left or the right side thrusters, we give it a negative 0.03 reward. Notice that this is a moderately complex reward function. The designers of the lunar lander application actually put some thought into exactly what behavior you want and codified it in the reward function to incentivize more of the behaviors you want and fewer of the behaviors like crashing that you don't want. You find when you're building your own reinforcement learning application, it usually takes some thought to specify exactly what you want or don't want and to codify that in the reward function. But specifying the reward function should still turn out to be much easier than specifying the exact right action to take from every single state, which is much harder for this and many other reinforcement learning applications. So the lunar lander problem is as follows. Our goal is to learn a policy pi that when given a state s as written here, takes an action a equals pi of s so as to maximize the return, the sum of discounted rewards. And usually for the lunar lander, we use a fairly large value for gamma. We'll use the value of gamma that's equal to 0.985. So pretty close to one. And if you can learn a policy pi that does this, then you successfully land this lunar lander. Exciting application and we're now finally ready to develop a learning algorithm, which will turn out to use deep learning on neural networks to come up with a policy to land the lunar lander. Let's go on to the next video where we'll start to learn about deep reinforcement learning.
[{"start": 0.0, "end": 6.88, "text": " The lunar lander lets you land a simulated vehicle on the moon."}, {"start": 6.88, "end": 12.200000000000001, "text": " It's like a fun little video game that's been used by a lot of reinforcement learning researchers."}, {"start": 12.200000000000001, "end": 14.76, "text": " Let's take a look at what it is."}, {"start": 14.76, "end": 20.16, "text": " In this application, you're in command of a lunar lander that is rapidly approaching"}, {"start": 20.16, "end": 25.400000000000002, "text": " the surface of the moon, and your job is to fire thrusters at the appropriate times to"}, {"start": 25.400000000000002, "end": 28.400000000000002, "text": " land it safely on a landing pad."}, {"start": 28.4, "end": 33.9, "text": " To give you a sense of what it looks like, this is the lunar lander landing successfully,"}, {"start": 33.9, "end": 38.9, "text": " and it's firing thrusters downward and to the left and right to position itself to land"}, {"start": 38.9, "end": 41.68, "text": " between these two yellow flags."}, {"start": 41.68, "end": 46.76, "text": " Or if the reinforcement learning algorithms policy does not do well, then this is what"}, {"start": 46.76, "end": 52.04, "text": " it might look like where the lander unfortunately has crashed on the surface of the moon."}, {"start": 52.04, "end": 58.5, "text": " In this application, you have four possible actions on every time step."}, {"start": 58.5, "end": 63.879999999999995, "text": " You could either do nothing, in which case the forces of inertia and gravity pull you"}, {"start": 63.879999999999995, "end": 69.84, "text": " toward the surface of the moon, or you can fire a left thruster."}, {"start": 69.84, "end": 73.6, "text": " When you see a little red dot come out on the left that's firing the left thruster,"}, {"start": 73.6, "end": 80.28, "text": " they'll tend to push the lunar lander to the right, or you can fire the main engine that's"}, {"start": 80.28, "end": 87.28, "text": " thrusting down the bottom here, or you can fire the right thruster, and that's firing"}, {"start": 87.28, "end": 90.72, "text": " the right thruster which will push you to the left."}, {"start": 90.72, "end": 97.96000000000001, "text": " And your job is to keep on picking actions over time so as to land the lunar lander safely"}, {"start": 97.96000000000001, "end": 101.52000000000001, "text": " between these two flags here on the landing pad."}, {"start": 101.52000000000001, "end": 106.44, "text": " In order to give the actions a shorter name, I'm sometimes going to call the actions nothing,"}, {"start": 106.44, "end": 112.03999999999999, "text": " meaning do nothing, or left, meaning fire the left thruster, or main, meaning fire the"}, {"start": 112.03999999999999, "end": 114.36, "text": " main engine downward, or right."}, {"start": 114.36, "end": 119.24, "text": " So I'm going to call the actions nothing, left, main, and right for short later in this"}, {"start": 119.24, "end": 120.24, "text": " video."}, {"start": 120.24, "end": 122.56, "text": " How about the state space of this MTP?"}, {"start": 122.56, "end": 129.28, "text": " The states are this position x and y, so how far to the left or right and how high up is"}, {"start": 129.28, "end": 134.1, "text": " it, as well as velocity x dot y dot."}, {"start": 134.1, "end": 137.28, "text": " How fast is it moving in the horizontal and vertical directions?"}, {"start": 137.28, "end": 142.74, "text": " And then also, is angle, so how far is the lunar lander tilted to the left or tilted"}, {"start": 142.74, "end": 143.74, "text": " to the right?"}, {"start": 143.74, "end": 146.16, "text": " Is angular velocity theta dot?"}, {"start": 146.16, "end": 151.64, "text": " And then finally, because a small difference in positioning makes a big difference in whether"}, {"start": 151.64, "end": 157.79999999999998, "text": " or not it's landed, we're going to have two other variables in the state vector, which"}, {"start": 157.79999999999998, "end": 162.92, "text": " we'll call L and R, which corresponds to whether the left leg is grounded, meaning whether"}, {"start": 162.92, "end": 168.67999999999998, "text": " or not the left leg is sitting on the ground, as well as R, which corresponds to whether"}, {"start": 168.67999999999998, "end": 171.83999999999997, "text": " or not the right leg is sitting on the ground."}, {"start": 171.83999999999997, "end": 180.04, "text": " So whereas x, y, x dot y dot theta, theta dot are numbers, L and R will be binary valued"}, {"start": 180.04, "end": 185.23999999999998, "text": " and can take on only values 0 or 1, depending on whether the left and right legs are touching"}, {"start": 185.23999999999998, "end": 186.23999999999998, "text": " the ground."}, {"start": 186.23999999999998, "end": 189.48, "text": " Finally, here's the reward function for the lunar lander."}, {"start": 189.48, "end": 195.51999999999998, "text": " If it manages to get to the landing pad, then it receives a reward between 100 and 140,"}, {"start": 195.51999999999998, "end": 200.48, "text": " depending on how well it's flown and gotten to the center of the landing pad."}, {"start": 200.48, "end": 205.17999999999998, "text": " We also give it an additional reward for moving toward or away from the pad."}, {"start": 205.17999999999998, "end": 208.88, "text": " So if it moves closer to the pad, it receives a positive reward."}, {"start": 208.88, "end": 213.2, "text": " If it moves away and drifts away, it receives a negative reward."}, {"start": 213.2, "end": 217.6, "text": " If it crashes, it gets a large negative 100 reward."}, {"start": 217.6, "end": 224.88, "text": " If it achieves a soft landing, that is a landing that's not a crash, it gets a plus 100 reward."}, {"start": 224.88, "end": 229.76, "text": " For each leg, the left leg or the right leg that gets grounded, it receives a plus 10"}, {"start": 229.76, "end": 230.76, "text": " reward."}, {"start": 230.76, "end": 236.48, "text": " And then finally, to encourage it not to waste too much fuel and fire thrusters unnecessarily,"}, {"start": 236.48, "end": 241.88, "text": " every time it fires the main engine, we give it a negative 0.3 reward."}, {"start": 241.88, "end": 247.76, "text": " And every time it fires the left or the right side thrusters, we give it a negative 0.03"}, {"start": 247.76, "end": 248.76, "text": " reward."}, {"start": 248.76, "end": 253.2, "text": " Notice that this is a moderately complex reward function."}, {"start": 253.2, "end": 258.04, "text": " The designers of the lunar lander application actually put some thought into exactly what"}, {"start": 258.04, "end": 265.32, "text": " behavior you want and codified it in the reward function to incentivize more of the behaviors"}, {"start": 265.32, "end": 270.28, "text": " you want and fewer of the behaviors like crashing that you don't want."}, {"start": 270.28, "end": 275.08, "text": " You find when you're building your own reinforcement learning application, it usually takes some"}, {"start": 275.08, "end": 280.67999999999995, "text": " thought to specify exactly what you want or don't want and to codify that in the reward"}, {"start": 280.67999999999995, "end": 281.88, "text": " function."}, {"start": 281.88, "end": 287.64, "text": " But specifying the reward function should still turn out to be much easier than specifying"}, {"start": 287.64, "end": 291.91999999999996, "text": " the exact right action to take from every single state, which is much harder for this"}, {"start": 291.91999999999996, "end": 294.67999999999995, "text": " and many other reinforcement learning applications."}, {"start": 294.67999999999995, "end": 299.44, "text": " So the lunar lander problem is as follows."}, {"start": 299.44, "end": 308.16, "text": " Our goal is to learn a policy pi that when given a state s as written here, takes an"}, {"start": 308.16, "end": 318.44, "text": " action a equals pi of s so as to maximize the return, the sum of discounted rewards."}, {"start": 318.44, "end": 323.36, "text": " And usually for the lunar lander, we use a fairly large value for gamma."}, {"start": 323.36, "end": 327.44, "text": " We'll use the value of gamma that's equal to 0.985."}, {"start": 327.44, "end": 329.8, "text": " So pretty close to one."}, {"start": 329.8, "end": 336.28, "text": " And if you can learn a policy pi that does this, then you successfully land this lunar"}, {"start": 336.28, "end": 337.28, "text": " lander."}, {"start": 337.28, "end": 341.96, "text": " Exciting application and we're now finally ready to develop a learning algorithm, which"}, {"start": 341.96, "end": 347.56, "text": " will turn out to use deep learning on neural networks to come up with a policy to land"}, {"start": 347.56, "end": 349.12, "text": " the lunar lander."}, {"start": 349.12, "end": 357.8, "text": " Let's go on to the next video where we'll start to learn about deep reinforcement learning."}]