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

n-step returns and TD(λ)

Watch one reward reach back n steps, then fade along a trace.


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 · 15.23 · RL BAYn 4 · G(t0) 0.33 · FULL FROM t5
01
Stage 1 of 6 · n-step return
An n-step return adds 4 rewards, then γ⁴ times the value it reaches. From t5 on, the episode ends first, so nothing is guessed.
Explain it simply

The chips show episode 1, from C at t0 to the right end. Under each chip is its 4-step return. It adds 4 rewards, then trusts the discounted value of the state it reaches. Near the end, the rewards run out first, so no guess is used.

Episode 1 moves C, B, A, B, C, B, C, D, E, then the right end. Its 4-step returns from t0 to t8 are 0.33, 0.33, 0.33, 0.33, 0.33, 0.73, 0.81, 0.90, 1.00.

states and tracesreturns and valuesn and λ weightstrue valueerror
episode 1 · n-step returnsn = 4guess V(C)full returns →00000000+1Ct0Bt1At2Bt3Ct4Bt5Ct6Dt7Et8+1t9G n=40.330.330.330.330.330.730.810.901.00real rewards0.00guess 0.66·V(C)0.334-step return0.33G0:4 = 0.33 · guess 0.66·V(C) = 0.33episode 1 · n-step returnsn = 4guess V(C)full returns →00000000+1Ct0Bt1At2Bt3Ct4Bt5Ct6Dt7Et8+1t9G n=40.330.330.330.330.330.730.810.901.00real rewards0.00guess 0.66·V(C)0.334-step return0.33G0:4 = 0.33 · guess 0.66·V(C) = 0.33
Toy: the 7-state random walk, γ = 0.9, V starts at 0.5
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
Gt:t+n=Rt+1+γRt+2+⋯+γnV(St+n)\sy{G}{out}{G_{t:t+n}} = \sy{R}{out}{R_{t+1}} + \sy{gamma}{param}{\gamma} \sy{R}{out}{R_{t+2}} + \dots + \sy{gamma}{param}{\gamma}^{\sy{n}{param}{n}} \sy{V}{out}{V(S_{t+n})}
G0:4=0+⋯+0.93⋅0+0.94⋅0.50=0.33G_{0:4} = 0 + \dots + 0.9^{3}\cdot 0 + 0.9^{4}\cdot 0.50 = 0.33

Add n discounted rewards, then a discounted guess from the state reached.

Common mix-ups

MYTHA larger n is always better: more real rewards, less guessing.

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

Predict, then reveal
3 CHECKS · PRO
Q01At step size 0.4, which n gives the lowest mean error?

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.