Policy Gradients and Actor–Critic #
Instead of estimating action values and choosing the maximum, policy-gradient methods adjust the parameters of the policy itself. A policy can learn to prefer one action while still assigning probability to others, or represent a distribution over continuous actions.
Course Content covered in this module:
- Policy Gradient Methods and the Policy Gradient Theorem
- REINFORCE with and without a baseline
- Actor-Critic methods and Advantage Actor-Critic (A2C)
1. Direct Policy Optimisation #
Let \( \pi_\theta(a\mid s) \) denote the policy. In a discrete action space, a softmax over action preferences produces a distribution. A policy-based method changes those preferences directly. The short corridor with switched actions illustrates why stochastic behaviour can matter: when distinct positions share the same observation and require different actions, always choosing one action can prevent progress.
2. Policy Gradient Theorem and REINFORCE ☆ #
For the discounted start-state objective, the theorem expresses the gradient as an occupancy-weighted average of score functions times action values. In episodic trajectory notation:
\[ \nabla_\theta J(\theta)= \mathbb{E}_{\pi_\theta}\!\left[ \sum_{t=0}^{T-1}\gamma^t q_{\pi_\theta}(S_t,A_t) \nabla_\theta\log\pi_\theta(A_t\mid S_t) \right]. \]REINFORCE replaces the unknown action value with the sampled return from that visit. After the episode, for each time step, apply the ascent increment \( \alpha\gamma^t G_t\nabla_\theta\log\pi_\theta(A_t\mid S_t) \) . The return \( G_t \) discounts rewards from time t; \( \gamma^t \) accounts for the step’s position relative to the start of the episode. The algorithm does not bootstrap and can have high variance across trajectories.
3. Baselines and Advantage ☆ #
A state-dependent baseline asks whether the outcome was better or worse than expected at that particular state. Use \( G_t-b(S_t) \) in place of \( G_t \) . An action-independent baseline does not change the expected policy gradient: at a fixed state, its expected score term is zero because the probabilities sum to one. A well-chosen baseline can reduce variance, but a poor baseline need not do so.
Example: If the baseline is 4 and a sampled return is 2, the actor’s weight for that action is −2. The outcome may be positive in absolute terms but below the expectation for that state. This is the intuition behind advantage: action value relative to state value.
4. One-Step Actor–Critic ☆ #
The actor represents the policy; the critic learns a value estimate. A one-step critic bootstraps from the next state, providing an immediate learning signal:
\[ \delta_t=R_{t+1}+\gamma V_w(S_{t+1})-V_w(S_t). \]Use zero successor value on termination. The critic moves towards its TD target with increment \( \alpha_w\delta_t\nabla_w V_w(S_t) \) ; the actor uses \( \delta_t \) in place of the full-return advantage, giving increment \( \alpha_\theta\gamma^t\delta_t\nabla_\theta\log\pi_\theta(A_t\mid S_t) \) for the discounted start-state convention. If the critic equals the true state value, the conditional expectation of the TD error is the true advantage; an approximate critic can introduce bias.
| Method | Actor’s signal | When available |
|---|---|---|
| REINFORCE | Sampled full return | At episode end |
| REINFORCE with baseline | Sampled full return minus state baseline | At episode end |
| One-step actor–critic | One-step TD error | After a transition |
| A2C | Advantage estimate, often from short rollouts and a value bootstrap | From synchronised rollout batches |
Practice Questions #
- A transition gives reward 2, with current value 5, next value 6 and discount 0.9. Calculate the TD error and explain how its sign affects the actor.
- Why does REINFORCE with a learned baseline still differ from one-step actor–critic?
- Why can a stochastic policy be useful in the short-corridor example?
References #
- Consolidated DRL slides, PDF pp. 324–361; recordings 12–13.