Policy Gradients and Actor-Critic Methods
Value-based reinforcement learning learns what each state is worth and acts greedily; policy-gradient methods skip the detour and optimize a parameterized policy directly by ascending the gradient of expected return. The policy gradient theorem makes this tractable through the log-derivative trick, turning an intractable gradient of an expectation into an expectation of a gradient.
╌╌╌╌
Value-based methods learn a value function and read a policy off it: estimate , then act greedily, . The policy is implicit, a byproduct of the value estimate, and the ties the approach to discrete action sets and to a deterministic, sometimes brittle, greedy rule. Policy-gradient methods invert the dependency: parameterize the policy itself as and adjust to make good trajectories more probable. There is no , the policy is stochastic by construction, and continuous action spaces come for free.
The parameterization is a design choice with concrete tensor shapes. A shared torso maps the state to a feature vector ; a policy head then reads a distribution off . The two standard heads differ only in what the head produces.
- Discrete actions. A linear head with emits one logit per action, , and a softmax turns the logits into probabilities, . The output is a length- probability vector; sampling picks an index. The score has the softmax form , the gradient of the chosen logit minus the policy-weighted average logit gradient.
- Continuous actions. For an -dimensional action the head emits a mean and a (log) standard deviation, and the action is drawn from a diagonal Gaussian . The log-density is , and its gradient in the mean is — the score pushes the mean toward actions that scored well. Parameterizing rather than keeps the standard deviation positive without a constraint.
The two paradigms differ in what they represent and how they improve it. The table fixes the contrast that the rest of the lesson refines.
| Value-based | Policy-based | |
|---|---|---|
| Learns | or | directly |
| Policy | implicit () | explicit, parameterized |
| Action space | discrete (needs the ) | discrete or continuous |
| Output | deterministic greedy | stochastic |
| Optimizes | Bellman error (indirect) | expected return (direct) |
| Convergence | can oscillate / diverge with approximation | smooth gradient ascent, local optimum |
The objective
Fix a parameterization. The agent interacts with a Markov decision process, drawing a trajectory by sampling and . The return is the discounted sum of rewards , and the quantity to maximize is its expectation under the trajectory distribution the policy induces.
The obstacle is that the expectation is taken over a distribution that itself depends on . We cannot push inside an expectation whose measure moves with , and the transition kernel is unknown, so we cannot differentiate the trajectory probability analytically. The policy gradient theorem removes both problems at once.
The policy gradient theorem
Write the trajectory probability as a product of the initial-state distribution, the policy, and the transitions:
The key device is the log-derivative trick (the score function identity): for any differentiable density, , which converts the gradient of a probability into a probability times the gradient of its log. That lets the gradient of the integral become an expectation, recoverable from sampled trajectories.
Every method in this lesson builds on this result. The gradient is an expectation, so a Monte Carlo average over sampled trajectories estimates it without a model; each term is a score weighted by how good the action turned out to be.
REINFORCE
The simplest realization replaces the unknown with the actual sampled return-to-go from a complete episode. This is unbiased: the sampled return is an unbiased estimate of its own expectation . The result is a Monte Carlo policy gradient.
- 1initialize policy parameters
- 2repeat
- 3sample an episode
- 4for to do
- 5return-to-go
- 6ascend
- 7until converged
- 8return
The estimator is correct in expectation but its variance is enormous. is a sum of many random rewards across a stochastic policy and stochastic dynamics, so a single episode's return can swing wildly, and the gradient estimate swings with it. Learning is slow and noisy, and the noise grows with the episode horizon.
Baselines and the advantage
Variance reduction is the central engineering problem of policy gradients. The first and most important tool is a baseline: subtract a state-dependent quantity from the return before weighting the score. This leaves the gradient unbiased for any that does not depend on the action.
The variance-minimizing choice of baseline is close to the state-value , the expected return from . Using replaces the raw return with the advantage, which measures how much better action is than the policy's average behavior in that state.
Centering the weight is what shrinks variance. Without a baseline every action in a high-reward state gets reinforced, including the mediocre ones; with the advantage, above-average actions gain probability and below-average actions lose it. The policy gradient takes its canonical, low-variance form.
Actor-critic
REINFORCE waits for a full episode to compute . Actor-critic methods estimate the value online with a second learned function, the critic, and let the actor (the policy) step every transition using a bootstrapped advantage rather than a Monte Carlo return. The critic supplies a low-variance, biased estimate where REINFORCE used a high-variance, unbiased one, trading a little bias for a large variance reduction.
The cheapest critic-based advantage is the one-step temporal-difference error, which estimates from a single transition and the critic:
The same drives both updates: the actor ascends , and the critic descends the squared TD error . The loop is symmetric and runs every step.
The synchronous batched form is A2C (advantage actor-critic): run several environment copies in parallel, collect a batch of transitions, and update both networks on the averaged gradient. A3C is the asynchronous predecessor, where many workers compute gradients on their own copies and apply them to shared parameters without locking, decorrelating the data the way a replay buffer does for value methods.
- 1initialize actor params and critic params
- 2repeat
- 3collect a batch of transitions from parallel actors
- 4for each transition do
- 5TD error = advantage estimate
- 6actor ascends
- 7critic fits the return
- 8until converged
- 9return
Generalized advantage estimation
The TD error is one extreme of a spectrum. A one-step advantage has low variance but high bias from the imperfect critic; the full Monte Carlo return has zero bias but high variance. The -step advantage interpolates by bootstrapping after real rewards. Generalized advantage estimation (GAE) takes an exponentially weighted average over all , governed by a single parameter .
The parameter controls the bias-variance trade-off, mirroring the role of in for value estimation. Typical values sit near , keeping most of the variance reduction while leaving the bias small. The estimator is a geometric blend: each TD residual enters the advantage with weight , so nearby residuals dominate and distant ones fade, which is what keeps variance in check.
| -step / | Bias | Variance | Bootstraps after | |
|---|---|---|---|---|
| One-step TD | high | low | reward | |
| GAE | tunable | tunable | weighted mix | |
| Monte Carlo | none | high | end of episode |
Trust-region methods
Vanilla policy gradients are fragile in step size. A learning rate that is fine in one region of policy space causes a catastrophic, irreversible collapse in another, because a small change in parameters can be a large change in the policy distribution . The remedy is to bound how far the policy may move per update, measuring distance in distribution space rather than parameter space.
TRPO (trust region policy optimization) makes this a hard constraint: maximize a surrogate advantage objective subject to a cap on the average KL divergence between the new and old policies. Write the probability ratio .
TRPO works but is heavy: it solves a constrained optimization with conjugate gradients and a line search every update. PPO (proximal policy optimization) achieves nearly the same effect with a first-order objective by clipping the ratio, removing the incentive to move it outside a small interval .
The clip is asymmetric in the sign of the advantage. For the objective flattens once exceeds , capping how much a good action's probability can rise in one step; for it flattens below . Either way the gradient is zeroed outside the interval, so a single batch cannot overshoot.
- 1initialize actor and critic
- 2repeat
- 3run policy , collect trajectories, store
- 4compute advantages by GAE and value targets
- 5for epochs over the batch do
- 6probability ratio
- 7
- 8clipped actor step
- 9critic regression
- 10
- 11until converged
- 12return
Deterministic and continuous control
The methods so far carry a stochastic policy. For continuous control an alternative learns a deterministic policy and pushes its gradient through a learned -critic via the chain rule, the deterministic policy gradient. DDPG combines this with a replay buffer and target networks, an off-policy actor-critic that is to continuous actions what DQN is to discrete ones.
DDPG is brittle because the critic overestimates. TD3 adds three fixes: two critics with a to curb overestimation, delayed actor updates, and target-policy smoothing. SAC instead makes stochasticity a first-class objective by adding the policy's entropy to the reward, the maximum-entropy formulation, which keeps the policy exploratory and the optimization well-conditioned.
The family spans on-policy and off-policy, discrete and continuous, stochastic and deterministic. The master table places each method on those axes.
| Method | Policy | Action space | On/off-policy | Key idea |
|---|---|---|---|---|
| REINFORCE | stochastic | discrete or continuous | on-policy | Monte Carlo policy gradient |
| A2C / A3C | stochastic | discrete or continuous | on-policy | learned critic gives the advantage |
| TRPO | stochastic | discrete or continuous | on-policy | KL-constrained trust region |
| PPO | stochastic | discrete or continuous | on-policy | clipped surrogate, first-order |
| DDPG | deterministic | continuous | off-policy | deterministic gradient + replay |
| TD3 | deterministic | continuous | off-policy | twin critics, delayed updates |
| SAC | stochastic | continuous | off-policy | maximum-entropy actor-critic |
Why PPO won practice
Goodfellow's text predates most of this family, so the citations are the papers themselves: the policy-gradient theorem,1 TRPO,2 GAE,3 PPO,4 DDPG,5 TD3,6 and SAC.7 Two observations connect this lesson to the full reinforcement-learning subject's policy-gradient module and to modern practice.
PPO became the default for a mundane reason: it is robust and simple. TRPO's KL constraint is provably better-behaved, but its conjugate-gradient inner loop is fiddly to implement and tune. PPO throws away the hard constraint for a clipped objective that any autodiff framework optimizes with plain SGD, and in exchange for a small loss in principle it gains enormous robustness across tasks and hyperparameters. That practicality is why PPO, not TRPO, is the algorithm behind the RLHF of the large-language-model alignment lesson and the next lesson: when the environment
is a reward model over text, PPO's stability is worth more than TRPO's tighter guarantee.
The stochastic/deterministic split maps onto exploration. On-policy stochastic methods (PPO, A2C) explore through the policy's own randomness and are simple but sample-hungry; off-policy deterministic methods (DDPG, TD3) reuse a replay buffer for sample efficiency but need injected exploration noise and are brittle. SAC's maximum-entropy objective is the reconciliation: off-policy sample efficiency and built-in stochastic exploration, which is why it became a default for continuous control. The choice among them is, at bottom, a choice about how the agent explores.
The reading is that the policy-gradient theorem is one clean idea — reweight action log-probabilities by how good the action was — and everything after is variance reduction (baselines, advantages, GAE) and step-size control (TRPO, PPO), with the continuous-control branch (DDPG, TD3, SAC) adding a critic-driven gradient for actions the of value methods cannot enumerate.
Takeaways
- Policy-gradient methods parameterize and maximize expected return by ascent, skipping the value-function detour and the ; they handle continuous actions and stochastic policies natively.
- The policy gradient theorem uses the log-derivative trick to write , an expectation estimable by sampling, with the unknown dynamics differentiated away.
- REINFORCE plugs in the Monte Carlo return ; it is unbiased but high-variance. A state-dependent baseline leaves the gradient unbiased and, taken as , yields the advantage that sharply reduces variance.
- Actor-critic learns the value online with a critic and steps on the TD error ; A2C/A3C parallelize it, and GAE dials bias against variance with .
- Trust-region methods bound the per-step policy change: TRPO by a hard KL constraint, PPO by clipping the probability ratio to .
- Continuous control specializes further: DDPG and TD3 push a deterministic gradient through a -critic off-policy, while SAC maximizes reward plus entropy.
- In practice: PPO displaced TRPO because a clipped first-order objective is far simpler and more robust, which is why it is the optimizer behind RLHF; the stochastic/deterministic split is at bottom a choice about how to explore.
Footnotes
- Sutton et al., Policy Gradient Methods for Reinforcement Learning with Function Approximation, NeurIPS 2000 — the policy gradient theorem and its actor-critic realization. ↩
- Schulman et al., Trust Region Policy Optimization, ICML 2015 — maximizes a surrogate advantage subject to a hard KL-divergence trust region on the policy update. ↩
- Schulman et al., High-Dimensional Continuous Control Using Generalized Advantage Estimation, ICLR 2016 — the -weighted advantage estimator that dials bias against variance. ↩
- Schulman et al., Proximal Policy Optimization Algorithms, 2017 — replaces TRPO's hard constraint with a clipped first-order surrogate, the default deep-RL policy optimizer. ↩
- Lillicrap et al., Continuous Control with Deep Reinforcement Learning (DDPG), ICLR 2016 — an off-policy deterministic actor-critic with replay and target networks for continuous actions. ↩
- Fujimoto et al., Addressing Function Approximation Error in Actor-Critic Methods (TD3), ICML 2018 — twin critics with a min, delayed actor updates, and target-policy smoothing to curb overestimation. ↩
- Haarnoja et al., Soft Actor-Critic, ICML 2018 — a maximum-entropy off-policy actor-critic that augments reward with policy entropy for exploration and stability. ↩
╌╌ END ╌╌