Log inStart free
LESSON 17.08 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

REINFORCE and the policy gradient theorem

Watch REINFORCE learn to balance a pole from its own episodes.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 17.08 · POLICY GRADIENT BAYUPDATE 1 · P(RIGHT) AT STEP 0 0.50
01
Stage 1 of 6 · The policy
The policy turns 4 state numbers into the chance to push right. All weights are 0, so it is 0.50.
Explain it simply

The cart rolls on a track with a pole on top. The policy reads four numbers: the cart's place and speed, and the pole's lean and turn speed. Each number has a weight. The policy adds them up and squashes the sum into a chance to push right.

A cart with a pole, and a table of 4 state numbers and 4 weights. The chance to push right is 0.50.

state, pushesweightsgradient, losschance, returns
the policy−2.4 m2.4 mpush rightstep 0swx−0.0330.00ẋ0.0340.00θ−0.0060.00θ−0.0070.00w·s = 0.00p(right) = 0.50left ← · → rightepisode 1 of update 1pole angle θ12°: the pole fallsstep 0p(right) = σ(w·s) = 0.50 at step 0the policy−2.4 m2.4 mpush rightstep 0swx−0.0330.00ẋ0.0340.00θ−0.0060.00θ−0.0070.00w·s = 0.00p(right) = 0.50left ← · → rightepisode 1 of update 1pole angle θ12°: the pole fallsstep 0p(right) = σ(w·s) = 0.50 at step 0
Toy: the 17.C2 cart-pole, 100-step cap, seed 1708
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
p=σ(w⋅s)=11+e−w⋅s\sy{p}{out}{p} = \sigma(\sy{w}{param}{w}\cdot \sy{s}{data}{s}) = \frac{1}{1+e^{-\sy{w}{param}{w}\cdot \sy{s}{data}{s}}}
z=w⋅s0=0.00,p=σ(0.00)=0.50z = w\cdot s_0 = 0.00,\quad p = \sigma(0.00) = 0.50

The chance to push right is the sigmoid of the weighted state.

Common mix-ups

MYTHA falling policy-gradient loss means a better policy.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With 4 episodes per update and α at 0.3, does the curve settle at 100 steps?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.