Gradient LabStart the lesson

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 lesson

Step by step

Story

Learn the strategy directly

Leo switches to learning the reminder strategy itself.

Concept

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.

Build

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.

Key idea

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.

Build

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.

Real life

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…

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: