Unit 3 of 10 · about 5 hours · derive, measure
Off-policy bootstrapping, the deadly triad and Baird's counterexample
This is the cheapest divergence in reinforcement learning: zero reward with an exactly representable truth. Replay buffers and target networks exist because of this failure.
You'll be able to
- Work through Baird's counterexample and name the update direction that causes instability.
- State the three triad elements and why any two alone avoid this failure.
- Run a controlled divergence demonstration with a stable comparator and keep the divergent trajectory.
Covers
Read
In this order, only the parts listed
0 of 2 done
- Off-policy divergence and Baird's counterexampleReinforcement Learning: An Introduction (2nd ed.) - Chapters 9 and 11
Section 11.2, printed pp. 260-263: the two-state versus warm-up (unstable whenever ), the seven-state Baird setup, Figure 11.1, and Figure 11.2 (semi-gradient TD on the left, semi-gradient DP on the right, both diverging from initial weights with )
- The deadly triadReinforcement Learning: An Introduction (2nd ed.) - Chapters 9 and 11
Section 11.3, printed pp. 264-265: the three-element definition (function approximation, bootstrapping, off-policy training), why uniform dynamic-programming sweeps count as off-policy, and Exercise 11.3 (semi-gradient Q-learning on Baird's counterexample)
Focus on
- In the warm-up, each visit multiplies by . Instability needs only , for every positive step size.
- Baird's truth is all zeros and is exactly representable with linearly independent features, yet off-policy semi-gradient TD(0) diverges for any . Representability never implied stability.
- Uniform dynamic-programming sweeps are off-policy here: uniform updates differ from the target policy's concentration on the seventh state.
- The on-policy distribution keeps the promise of future reward payable. Off-policy lets a promise be made, then forgotten after an action the target policy never takes.
Common mistakes · 3
- Blaming reward or representation. Baird has zero reward everywhere and an exact, linearly independent representation.
- Shrinking the step size as a fix. A smaller only slows the blowup because the per-update factor still exceeds 1.
- Trusting expected (dynamic-programming) updates as safe. Figure 11.2 shows semi-gradient DP diverging too; only the on-policy distribution change stabilizes.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.In the warm-up with and , what is the per-update multiplier?Answer
. Each visit grows by about 8 percent.
2.Why is uniform dynamic programming off-policy training in this example?Answer
Its update distribution is uniform over states while the target policy concentrates on the seventh state. The triad's off-policy leg is about distributions, not about sampling noise.
3.The true values are all zero and exactly representable. Why is divergence not a contradiction?Answer
Representability does not imply stability. Under the wrong update distribution the semi-gradient direction at points away from it.
4.Which single triad leg would you remove to keep bootstrapping and approximation?Answer
Train on-policy, so ratios are 1 and visitation matches the target policy. Removing bootstrapping (Monte Carlo targets) is the alternative, at steep sample cost.
Practice
- Deep-ML 557: Baird's Counterexample, Off-Policy TD Divergence
Implement
bairds_counterexample. The tests check the no-update identity on an empty update list and one semi-gradient step from the book's initial weights
You're done when
Your own script diverges from the book's start while the on-policy twin stays bounded, and Deep-ML 557 passes.
Only when you can do this without notes.
Leads to
Notes
Resources · 1 for this unit, 11 more in the section
- Reinforcement Learning: An Introduction (2nd ed.) - Chapters 9 and 11Richard Sutton and Andrew Barto · required
The authors post the full second edition free at incompleteideas.net; cite the printed page numbers. Study Sections 9.1 to 9.4 (value error, semi-gradient TD, linear methods) and Sections 11.1 to 11.3 and 11.6 (off-policy divergence, the deadly triad, why the Bellman error is not learnable). Reproduce Baird's counterexample (Section 11.2, Figure 11.1) and show the weights diverge under off-policy semi-gradient TD.
Also in this section
- Berkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Value-Based RL and Q-Learning in PracticeUC Berkeley · primary
Slides are public at https://rail.eecs.berkeley.edu/deeprlcourse/static/slides/lec-N.pdf; current videos are not, and the public Fall 2023 playlist numbers lectures differently. Study Lecture 7 (value-based RL) and Lecture 8 (Q-learning in practice: replay, target networks, double Q-learning). Work the DQN part of Homework 3 (
src/agents/dqn_agent.py, CartPole then LunarLander with double DQN) on CPU or one small GPU; the Atari run is optional. The homework pinsgym==0.25.2, which fails on NumPy 2, so port it to Gymnasium (terminatedandtruncated) or pinnumpy<2in its own environment, and turn off its forced WandB logging. - Stanford CS224R Spring 2026 - Q-Learning and Off-Policy MethodsStanford University · support
Use Lecture 06 (Q-learning) and the TA Q-learning tutorial (
material/CS224R_Tutotial_Max.pdf) as a second derivation of fitted Q-iteration, targets and overestimation. Its homeworks run on cloud GPUs; follow the Stanford honor code for course materials. - Playing Atari with Deep Reinforcement LearningDeepMind · required
Read the algorithm, replay and target-network design plus experimental protocol. Reproduce DQN on a small discrete environment, then ablate replay and target networks rather than attempting an Atari score reproduction.
- Deep Reinforcement Learning with Double Q-LearningDeepMind · required
Derive the action-selection and action-evaluation split, construct a noisy maximization example and compare DQN with Double DQN using identical samples and tuning budgets.
- Dueling Network Architectures for Deep Reinforcement LearningWang et al. (ICML 2016) · support
Read the dueling architecture and its aggregation equations (the mean-subtracted form). Implement it as an optional head and test that the value and advantage streams are identifiable only up to the stated constraint.
- CleanRL DQNCleanRL · support
Read the single-file DQN implementation and documented benchmark details after the blank-file update passes. Trace replay, target, seeding, termination and evaluation semantics. The script expects the
final_infoandfinal_observationkeys of older Gymnasium releases; on Gymnasium 1.x (next-step autoreset) it logs no episode returns and raisesKeyErrorat truncation, so run it in an environment withgymnasium==0.29.1or patch those lines and say so. - Hands-on Modern RL - From Q-Learning to DQNWalking Labs · support
Use Sections 5.1 to 5.4, with the masked target on the components page (the formula on the first page omits the terminal mask).
code/chapter04_dqn/dqn_cartpole.pytrains CartPole on CPU in about two minutes. Treat score claims as hypotheses requiring local seed and version evidence. Pin commit 9231bab of walkinglabs/hands-on-modern-rl; itscode/chapterNNfolders do not follow the site chapter numbers. - Deep-ML - Function Approximation and DQN ProblemsDeep-ML · support
Use named problems as closed-book checks after your own implementation passes: 530 (semi-gradient TD(0)), 556 (deadly-triad instability), 557 (Baird's counterexample), 537 (experience replay) and 477 (double Q-learning). Read each problem's tests before trusting its statement.
- Reinforcement Learning Control Laboratory - Deep Value CoreRoadmap-Final · required
Implement DQN and Double DQN with replay and target state, fixed-batch target tests, checkpoint and resume, overestimation evidence and injected online-target, detach, action-gather and replay defects.
- Gymnasium - Time Limits and Vector AutoresetFarama Foundation · reference
Read Termination, Truncation, Importance in learning code and Solution in the time-limits tutorial, plus the vector autoreset note at https://farama.org/Vector-Autoreset-Mode. Next-step autoreset is the default for Gymnasium 1.x vector environments; on Gymnasium 1.4.0 the step after an episode ends returns reward 0 with both flags false and is not a transition.
- Gymnasium - Env.reset and seedingFarama Foundation · reference
Read the
Env.resetentry for the seeding contract: an integer seed resets the environment PRNGnp_random, and a laterresetwithseed=Nonecontinues it, so seed once right after creation.