Deep RL I: Function Approximation and Stability

Deep RL replaces tables with learned representations, which introduces moving targets and feedback loops. This stage makes semi-gradient assumptions, replay state, target networks and the deadly triad observable before larger policies hide an unstable update.

Section 3 of 12 · 10 units · about 40 hours

0/10

By the end you can Reproduce a controlled deadly-triad failure, implement DQN and Double DQN with fixed-batch oracles, and explain stability across seeds using replay, target, value-scale and gradient evidence rather than final return alone.

Units

Build it

Mini project · about 10 to 14 hours

Stable neural value learning with frozen targets

Build the policylab deep value laboratory: a CartPole DQN baseline with replay and frozen targets, fixed-batch defect tests, overestimation evidence and full checkpoint resume. The run keeps raw curves and failures so later policy work inherits honest diagnostics.

  1. 1Reproduce off-policy semi-gradient divergence from the book start across a seed set beside its bounded solid-action on-policy twin, and pass Deep-ML 530 and Deep-ML 557 on CPU.
  2. 2Extend the Hands-on Modern RL CartPole DQN in deep/ with explicit replay and target state, pass Deep-ML 537, and separate exploratory training from greedy evaluation on held-out seeds.
  3. 3Write frozen-batch DQN target tests that catch an online-target swap, a missing detach, a wrong gather and a replay corruption each, plus a vector autoreset probe that drops the reset handshake instead of storing it.
  4. 4Sweep target lag under matched step budgets following Berkeley CS285 Homework 3, compare double against vanilla targets on identical samples passing Deep-ML 477, and keep Q scale, TD-error spread and gradient norm curves.
  5. 5Checkpoint parameters, optimizer, replay contents and every RNG stream at an episode boundary, prove interruption equivalence against an uninterrupted run, and catch stale-target and evaluation-leakage defects.
  6. 6Train CartPole across several seeds at a stated interaction budget on CPU, regenerate every chart from per-seed raw records including failures, and report stability with uncertainty rather than a best score.
What you hand in
  • The deep/ DQN laboratory with replay, frozen targets and full checkpoints.
  • Tests: frozen-batch target defects, replay corruption, autoreset handling and resume equivalence.
  • Lag sweep, double estimator comparison and diagnostics with multi-seed raw records and retained failures.
How to check it
How it's graded

Divergence honesty

Pass: Baird diverges on every seed while the solid-action twin stays bounded, and twins differ only in distribution.

Great: A slowed step size is shown to delay rather than remove the blowup.

Target correctness

Pass: Frozen-batch tests fail on each injected target, detach, gather and replay defect.

Great: A live-sample loss drop is exposed as scale shrinkage by the frozen batch.

Resume equivalence

Pass: Interrupted resume continues the identical loss trajectory with full state restored.

Great: Dropping each checkpoint piece in turn shows which resume check then fails.

Stability evidence

Pass: Lag sweep and double comparison use matched budgets with all seeds and failures retained.

Great: A losing configuration is kept and explains the operating point choice.

Resources

  • Berkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Value-Based RL and Q-Learning in PracticeUC Berkeley

    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 pins gym==0.25.2, which fails on NumPy 2, so port it to Gymnasium (terminated and truncated) or pin numpy<2 in its own environment, and turn off its forced WandB logging.

  • Reinforcement Learning: An Introduction (2nd ed.) - Chapters 9 and 11Richard Sutton and Andrew Barto

    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.

  • Playing Atari with Deep Reinforcement LearningDeepMind

    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

    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.

  • Reinforcement Learning Control Laboratory - Deep Value CoreRoadmap-Final

    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.

  • Stanford CS224R Spring 2026 - Q-Learning and Off-Policy MethodsStanford University

    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.

  • Dueling Network Architectures for Deep Reinforcement LearningWang et al. (ICML 2016)

    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

    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_info and final_observation keys of older Gymnasium releases; on Gymnasium 1.x (next-step autoreset) it logs no episode returns and raises KeyError at truncation, so run it in an environment with gymnasium==0.29.1 or patch those lines and say so.

  • Hands-on Modern RL - From Q-Learning to DQNWalking Labs

    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.py trains 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; its code/chapterNN folders do not follow the site chapter numbers.

  • Deep-ML - Function Approximation and DQN ProblemsDeep-ML

    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.

  • Gymnasium - Time Limits and Vector AutoresetFarama Foundation

    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

    Read the Env.reset entry for the seeding contract: an integer seed resets the environment PRNG np_random, and a later reset with seed=None continues it, so seed once right after creation.