Lessons › Chapter 13: Reinforcement learning
Policy gradients
Instead of a Q-table, a policy gradient method learns the policy directly: a network that gives a probability for each action. A robot arm starts out unsure what to do.
Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.
Start the interactive lessonStep by step
Learn the strategy directly
Leo switches to learning the reminder strategy itself.
A policy that outputs chances
Instead of a Q-table, a policy gradient method learns the policy directly: a network that gives a probability for each action. A robot arm starts out unsure what to do.
Try an episode
Play a full attempt, picking actions at random according to those probabilities. This time the arm happened to grip, and it picked up the block: reward +1.
Reinforce what worked
Nudge the network so the actions from that successful attempt become a bit more likely. Failed attempts get nudged the other way.
Over many tries, it gets good
Thousands of attempts later, the policy reliably does the right thing. A modern version of this idea (PPO) is also the workhorse behind RLHF for chat assistants.
In real life: robots learning to grasp
Research labs train robot arms to pick up unfamiliar objects with methods like this, often practicing in simulation first. The same family of methods tunes chat assistants with human feedback and has learned to play complex games.
Quick check: After an episode with a high reward, a policy-gradient method…
- Makes the actions it took more likely (correct)
- Deletes the policy
- Makes every action equally likely
It increases the probability of the actions that led to the good outcome.
Pseudocode
policy = network: state → probability of each action
play an episode, sampling actions from the policy
if the total reward was good:
make the actions you took more likely
else:
make them less likely
repeat over many episodes
Key terms
- policy gradient
- A method that directly adjusts the policy’s action probabilities toward actions that led to high reward.
In the news
Recent models and papers that build on this idea: