Unit 1 of 10 · about 4 hours · explain, derive
Value-function approximation, linear features and state aggregation
Tables cannot cover large or continuous state spaces. Linear approximation is the first generalizer, and its error measure and sampling assumptions decide whether every later deep update is stable.
You'll be able to
- Explain why value prediction with shared weights generalizes across states, and what it can no longer represent.
- Derive the stochastic-gradient update for the mean-squared value error and state the distribution it assumes.
- Predict how state aggregation biases each group's value toward its most visited members.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Approximation as supervised examples and the value errorReinforcement Learning: An Introduction (2nd ed.) - Chapters 9 and 11
Sections 9.1 and 9.2, printed pp. 198-199: the update-as-example view (each update is one pair ) and the mean-squared value error as Eq. 9.1
The authors post the full text free at incompleteideas.net. Read the sections there and cite the printed pages above.
- Linear methods, state aggregation and the random-walk demoReinforcement Learning: An Introduction (2nd ed.) - Chapters 9 and 11
Sections 9.4 and 9.5, printed pp. 203-210: with gradient , Example 9.1 and Figure 9.1 (1000-state random walk, 10 groups of 100 states)
- Fitted value iteration and the curse of dimensionalityBerkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Value-Based RL and Q-Learning in Practice
Lecture 7 (Value-Based RL), Part 3, slides 10 to 14: fitted value iteration, the curse of dimensionality, and fitted Q-iteration as the sample-based bridge
Focus on
- Each tabular update is one supervised example . Approximation shares the correction across states through the weight vector .
- The error measure weights states by the visitation distribution . An unweighted fit optimizes a different objective than on-policy performance.
- In the linear case the gradient is the feature vector itself, so one update moves every state that shares features.
- Figure 9.1 shows the consequence: each aggregation group learns one constant, pulled toward its most visited members, with abrupt boundaries between groups.
Common mistakes · 3
- Minimizing error on a uniform state sample instead of under . A uniform sweep is already off-policy training, which the next units show can diverge.
- Reading more features as strictly better. Under on-policy linear gradients they approach the value error minimum, but under bootstrapping or off-policy data that guarantee lapses.
- Blaming the step size for a representation limit. No choice of lets a coarse aggregation represent inside a group.
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.Why does the book call each update a training example?Answer
Each update names an input state and a desired output target, exactly the interface a supervised approximator expects. The reinforcement learning part is how is constructed.
2.Two states share all features. What happens when one of them is updated?Answer
Both estimates move together, because the update changes the shared . The gradient is identical for both states.
3.In Figure 9.1, why do the leftmost group values sit above their members' unweighted mean?Answer
Right members of those groups carry far larger weight (state 100 outweighs state 1 more than threefold), so the group constant fits them more closely.
4.Does the value error optimum change when visitation changes?Answer
Yes. weights by , so a new visitation distribution defines a new objective with generally a new best .
Practice
- Sutton and Barto Chapter 9: Exercises 9.7 and 9.8
Printed p. 237: derive the learning algorithm for a semi-linear logistic unit from Eq. 9.7 with no gradient notation, then repeat the derivation with cross-entropy loss
You're done when
You derive the linear update without notes and predict the direction of the aggregation bias for a skewed visitation before opening Figure 9.1.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 10 more in the 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. - 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
- 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.