Unit 4 of 11 · about 4 hours · derive, implement
Learned value baselines, critic targets and actor-critic dependencies
A critic gives credit before an episode ends, but its errors can enter the actor's learning signal. The update order and the target's policy identity are part of the algorithm.
You'll be able to
- Explain why a learned Monte Carlo baseline and a bootstrapped actor-critic have different bias sources.
- Derive one-step critic targets and actor weights with separate termination and trajectory-boundary semantics.
- Implement actor and critic updates with explicit target snapshots and gradient ownership.
Covers
Read
In this order, only the parts listed
0 of 3 done
- CS 185/285 Lecture 6: Actor-CriticBerkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Policy Gradients, Actor-Critic and Advanced Policy Gradients
Slides 4 to 6, 8 to 12, 16 to 17 and 21 to 22: value fitting, bootstrap targets, batch and online actor-critic, critics versus baselines
Do not adopt the variance labels as universal guarantees. Stop before off-policy actor-critic; that belongs to the continuous-control section.
- Sutton and Barto: actor-critic distinctionReinforcement Learning: An Introduction (2nd ed.) - Chapter 13
Chapter 13, Section 13.5, Actor-Critic Methods, printed pp. 331 to 332; the One-step Actor-Critic (episodic) box
The authors post the full text free on their Incomplete Ideas website. Skip the eligibility-trace algorithm box.
- Homework 2: baseline update dependenciesBerkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Policy Gradients, Actor-Critic and Advanced Policy Gradients
PGAgent.update, steps 1 to 4, and_estimate_advantage, the baseline branchRead the starter as an update-order audit, not runnable completed code. Its Gym and WandB setup needs porting; implement the update in policylab instead.
Focus on
- Use TD error, TD(0), bootstrapping and Monte Carlo versus TD bias and variance as the earlier result. The new question is how that target weights an action score.
- For a snapshot critic, and , where marks true termination. A truncation needs the final pre-reset observation's value.
- Freeze actor weights and critic regression targets for the specified update. Detach the actor's advantage and the bootstrap target; a shared encoder may still receive the separately declared value-loss gradient.
- A fixed imperfect baseline subtracted from full returns preserves the score expectation. An imperfect next-state value inside a return target can create action-dependent bias.
Common mistakes · 3
- Refitting the critic and silently recomputing actor weights partway through the same update. That changes the declared estimator.
- Treating the baseline network as a critic merely because it is learned. Bootstrapping the action assessment is the relevant distinction here.
- Bootstrapping from a reset observation at truncation. That credits the old action with the next episode's value.
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.Can a perfect value function make the one-step TD residual an unbiased advantage estimate?Answer
Yes. Conditional on the state and action, the expected reward plus discounted next-state value equals the action value, so subtracting the state value yields advantage.
2.What bias can an imperfect next-state value introduce?Answer
Its expected bootstrap error can depend on the current action through the transition law. It therefore need not vanish when multiplied by the action score.
3.Does detaching the advantage forbid a shared actor-critic encoder?Answer
No. It prevents the policy-loss gradient from flowing through the advantage calculation. The encoder can still receive gradients through policy logits and the separate value loss.
You're done when
Your update matches all three boundary cases, target tensors receive no gradient, and you can draw the actor, critic and rollout dependency graph.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 11 more in the section
- Berkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Policy Gradients, Actor-Critic and Advanced Policy GradientsUC 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 Lectures 5 (policy gradients), 6 (actor-critic), 9 and 10 (advanced policy gradients). Work Homework 2 (
src/agents/pg_agent.py: return estimators, reward-to-go, a neural baseline and a GAE sweep); its runs take seconds to minutes on a laptop CPU. 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.) - Chapter 13Richard Sutton and Andrew Barto · required
The authors post the full second edition free at incompleteideas.net; cite the printed page numbers. Study Sections 13.1 to 13.5 and 13.7: the policy-gradient theorem, REINFORCE, REINFORCE with baseline, actor-critic and Gaussian policies. Reproduce Example 13.1 (the short corridor) with and without a baseline, and derive the gradient and baseline result in the notation of the shared trajectory schema.
Also in this section
- Stanford CS224R Spring 2026 - Policy Gradients and Actor-CriticStanford University · support
Use Lectures 03 (policy gradients) and 04 (actor-critic) as a second derivation, and the Homework 2 PPO handout for its exact GAE recursion and its note that several epochs on one batch is not strictly on-policy. Its runs need cloud GPUs, and its actor is a truncated normal, not a tanh-squashed Gaussian. Follow the Stanford honor code for course materials.
- Proximal Policy Optimization AlgorithmsOpenAI · required
Read the clipped objective, implementation variants and experiments. Build hand cases for positive and negative advantages, compare clipped and unclipped losses and show that clipping alone does not enforce a hard KL bound.
- High-Dimensional Continuous Control Using Generalized Advantage EstimationSchulman et al. · required
Derive GAE from TD residuals, implement backward recursion with terminal and truncation masks and sweep and on fixed trajectories before training.
- The 37 Implementation Details of Proximal Policy OptimizationHuang et al. (ICLR Blog Track 2022) · required
Use the core and continuous-action details as an audit checklist for your PPO: vectorized environments, advantage normalization, value clipping, entropy, global gradient clipping, learning-rate annealing and observation and reward normalization. For each detail you adopt, show its effect with an ablation on your own task.
- Spinning Up - Intro to Policy Optimization and PPOOpenAI · support
Read Part 3 (Intro to Policy Optimization: the simplest policy gradient, reward-to-go, the expected grad-log-prob lemma, baselines) and the PPO page's background, which states that the clipped objective has no hard KL bound. Do not install its code: it needs TensorFlow 1, MPI and the retired Gym stack.
- CleanRL PPOCleanRL · support
Use the single-file implementation and implementation-details notes as a post-implementation audit. Trace rollout shapes, advantage calculation, minibatch epochs, ratios, clipping, value loss, entropy, seeding and environment semantics. Like the DQN script it reads
final_info, which Gymnasium 1.x next-step autoreset no longer provides; pingymnasium==0.29.1or patch the episode logging. - Hands-on Modern RL - REINFORCE, Actor-Critic and PPOWalking Labs · support
Use the REINFORCE page, the actor-critic chapter and the PPO and GAE pages for worked numbers: the three advantage-sign cases and the five-step GAE table.
code/chapter05_policy_gradient/reinforce_cartpole.pyandcode/chapter07_ppo/ppo_from_scratch.pyrun on CPU in minutes. Audit completion masks against the Gymnasium docs (its GAE helper cuts the bootstrap on truncation) and do not adopt its KL sketch as a reference. Pin commit 9231bab of walkinglabs/hands-on-modern-rl; itscode/chapterNNfolders do not follow the site chapter numbers. - Deep-ML - Policy-Gradient ProblemsDeep-ML · support
Use named problems as closed-book checks after your own implementation passes: 481 (REINFORCE with baseline), 482 (one-step actor-critic), 485 (PPO clipped surrogate with clip diagnostics) and 487 (GAE with episode boundaries). Read each problem's tests before trusting its statement.
- Reinforcement Learning Control Laboratory - Policy CoreRoadmap-Final · required
Complete REINFORCE with baseline, actor-critic, GAE and PPO requirements. Match hand-computed log probabilities, advantages, ratios and clipped losses and diagnose stale-policy, ratio, GAE and evaluation leakage defects.
- Soft Actor-Critic: action-bound density correctionHaarnoja et al. · reference
Appendix C, Enforcing Action Bounds, Equations 20 and 21 in arXiv:1801.01290v2. Supplies the change-of-variables derivation missing from the pool's action-clipping checklist; do not study SAC training here.
- Gymnasium vector autoreset modesFarama Foundation · reference
Read Next-Step Mode, Same-Step Mode and Disabled Mode in the official autoreset explainer, then SyncVectorEnv's reset and step API. Check against Gymnasium 1.4.0; pages read 2026-10-14. Supplies current rollout semantics missing from the older PPO examples.