Simple Algorithm
Artificial Intelligence · Hidden Layer · 24 min

Policy Gradients & Actor–Critic

Optimizing behavior directly.

Q-learning acts by maximizing a learned value table. Policy-gradient methods skip the max: they parameterize the policy itself and climb the gradient of expected return. That handles continuous actions and policies that must be random to be optimal, and with a learned critic it becomes actor–critic, the template behind A2C, PPO and SAC.

What you’ll learn

  • Derive the policy-gradient theorem in its likelihood-ratio form and turn it into the REINFORCE algorithm.
  • Prove that baselines leave the gradient unbiased, and derive the variance-minimizing constant baseline.
  • Build a one-step actor–critic from the TD error, and explain generalized advantage estimation as a bias–variance dial.
  • Explain when policy-based methods beat value-based ones, and what makes them fragile.

Why optimize the policy directly?

Value-based methods such as Q-learning learn Q(s,a)Q(s,a) and act greedily on it. Policy-gradient methods instead give the policy its own parameters θ\theta and improve it by gradient ascent on the expected return,

J(θ)=Eπθ[G0]=Vπθ(s0),θ←θ+α ∇J(θ)^.J(\theta)=\E_{\pi_\theta}\big[G_0\big]=V^{\pi_\theta}(s_0),\qquad\theta\leftarrow\theta+\alpha\,\widehat{\nabla J(\theta)}.

For discrete actions the usual choice is a softmax over learned preferences, for continuous actions a Gaussian whose mean (and often spread) a network outputs:

πθ(a∣s)=ehθ(s,a)∑behθ(s,b)ora∼N(μθ(s), σθ(s)2)\pi_\theta(a\mid s)=\frac{e^{h_\theta(s,a)}}{\sum_be^{h_\theta(s,b)}}\qquad\text{or}\qquad a\sim\mathcal N\big(\mu_\theta(s),\,\sigma_\theta(s)^2\big)
Small changes in θ\theta change the policy smoothly. An argmax over action values can jump from one action to another after a tiny change in QQ.

Why bother? Three reasons. With many or continuous actions, max⁡aQ(s,a)\max_aQ(s,a) is itself an optimization problem at every step, while sampling from πθ\pi_\theta is cheap. Some problems need stochastic policies to be optimal: in games such as rock–paper–scissors, and whenever the agent cannot tell states apart. And smooth parameterizations give better convergence guarantees with function approximation. The costs are high-variance gradient estimates, local optima, and data that must usually come from the current policy.

Here is a problem where randomness is essential (Sutton & Barto, Example 13.1). A corridor has three cells before the goal, and each step costs 1. In the first cell left bumps into the wall and right moves on. In the second cell the actions are switched: right moves back and left moves forward. In the third, right reaches the goal. The agent's observation is the same in every cell, so its policy is a single number: the probability pp of choosing right.

Predict before you look

Which probability pp of choosing right, used in every cell, maximizes the expected return from the first cell?

Show the answer

0.59

Always going right is a trap: the switched cell sends you back. Always going left stalls at the first wall. The optimum mixes them, p∗=2−2≈0.59p^*=2-\sqrt2\approx0.59, with expected return −(6+42)≈−11.7-(6+4\sqrt2)\approx-11.7; the derivation follows.

DerivationThe corridor, solved
  1. v1=−1+p v2+(1−p) v1,v2=−1+p v1+(1−p) v3,v3=−1+(1−p) v2v_1=-1+p\,v_2+(1-p)\,v_1,\qquad v_2=-1+p\,v_1+(1-p)\,v_3,\qquad v_3=-1+(1-p)\,v_2

    Let v1,v2,v3v_1,v_2,v_3 be the values of the three cells (γ=1\gamma=1). Each step costs 1, and the goal is worth 0:

  2. v2=−3−pp(1−p),v1=−2(2−p)p(1−p)v_2=-\frac{3-p}{p(1-p)},\qquad v_1=-\frac{2(2-p)}{p(1-p)}

    The first equation gives v1=v2−1/pv_1=v_2-1/p. Substitute it and the third equation into the second, and solve:

  3. p∗=2−2≈0.586,v1(p∗)=−(6+42)≈−11.66p^*=2-\sqrt2\approx0.586,\qquad v_1(p^*)=-\big(6+4\sqrt2\big)\approx-11.66

    Maximize v1v_1. The derivative of (2−p)/(p−p2)(2-p)/(p-p^2) vanishes where p2−4p+2=0p^2-4p+2=0:

  4. A deterministic policy (p=0p=0 or 11) never reaches the goal. An ε-greedy policy over action values with ε=0.1\varepsilon=0.1 can only express p=0.95p=0.95 or p=0.05p=0.05, worth about −44-44 and −82-82. A parameterized stochastic policy can represent p∗p^*.

AspectValue-based (Q-learning, DQN)Policy-based (REINFORCE, actor–critic)
What is learnedaction values; the policy is arg max⁡aQ\argmax_aQthe policy itself (often a critic too)
Action spacessmall and discreteany, including continuous
Stochastic optimal policiesnot representable by a greedy policynatural
Dataoff-policy, replayusually on-policy (off-policy variants exist)
Typical weaknessinstability with function approximationhigh variance, sample hunger, local optima

The policy-gradient theorem

The objective is an expectation over trajectories τ=(s0,a0,r1,s1,… )\tau=(s_0,a_0,r_1,s_1,\dots) whose distribution depends on θ\theta: J(θ)=Eτ∼pθ[R(τ)]J(\theta)=\E_{\tau\sim p_\theta}[R(\tau)] with R(τ)=∑tγtrt+1R(\tau)=\sum_t\gamma^tr_{t+1}. How can you differentiate it without knowing the dynamics?

DerivationFrom the log-derivative trick to the theorem
  1. ∇θJ=∑τR(τ) ∇θpθ(τ)=∑τpθ(τ) R(τ) ∇θlog⁡pθ(τ)=Eτ[R(τ) ∇θlog⁡pθ(τ)]\nabla_\theta J=\sum_\tau R(\tau)\,\nabla_\theta p_\theta(\tau)=\sum_\tau p_\theta(\tau)\,R(\tau)\,\nabla_\theta\log p_\theta(\tau)=\E_\tau\big[R(\tau)\,\nabla_\theta\log p_\theta(\tau)\big]

    Use ∇p=p ∇log⁡p\nabla p=p\,\nabla\log p. The gradient of an expectation becomes an expectation of a gradient:

  2. log⁡pθ(τ)=log⁡p(s0)+∑t[log⁡πθ(at∣st)+log⁡P(st+1∣st,at)] ⟹ ∇θlog⁡pθ(τ)=∑t∇θlog⁡πθ(at∣st)\log p_\theta(\tau)=\log p(s_0)+\sum_t\Big[\log\pi_\theta(a_t\mid s_t)+\log P(s_{t+1}\mid s_t,a_t)\Big]\ \Longrightarrow\ \nabla_\theta\log p_\theta(\tau)=\sum_t\nabla_\theta\log\pi_\theta(a_t\mid s_t)

    A trajectory's probability factorizes into start, policy and dynamics terms. Only the policy terms depend on θ\theta, so the unknown dynamics drop out:

  3. ∇θJ=Eτ[∑tγt Gt ∇θlog⁡πθ(at∣st)],Gt=∑k≥tγk−trk+1\nabla_\theta J=\E_\tau\Big[\sum_t\gamma^t\,G_t\,\nabla_\theta\log\pi_\theta(a_t\mid s_t)\Big],\qquad G_t=\sum_{k\ge t}\gamma^{k-t}r_{k+1}

    Causality. A reward earned before time tt cannot depend on ata_t, and given everything up to sts_t the score has mean zero: E[∇log⁡πθ(at∣st)]=∑a∇πθ(a∣st)=∇1=0\E\big[\nabla\log\pi_\theta(a_t\mid s_t)\big]=\sum_a\nabla\pi_\theta(a\mid s_t)=\nabla1=0. Dropping those terms leaves the return from time tt on:

  4. ∇θJ=∑sηγ(s)∑aQπ(s,a) ∇θπθ(a∣s)\nabla_\theta J=\sum_s\eta_\gamma(s)\sum_aQ^\pi(s,a)\,\nabla_\theta\pi_\theta(a\mid s)

    Since E[Gt∣st,at]=Qπ(st,at)\E[G_t\mid s_t,a_t]=Q^\pi(s_t,a_t), grouping time steps by state, with discounted visit frequencies ηγ(s)=∑tγtPr⁡(st=s)\eta_\gamma(s)=\sum_t\gamma^t\Pr(s_t=s), gives the policy-gradient theorem (Sutton, McAllester, Singh & Mansour, 2000):

Two things are remarkable. The state distribution depends on θ\theta, yet its derivative never appears. And the dynamics are only ever sampled, never modeled, so the estimate is model-free. The score ∇log⁡πθ\nabla\log\pi_\theta has simple forms: for a tabular softmax, ∂log⁡π(a∣s)/∂θs,b=1[a=b]−π(b∣s)\partial\log\pi(a\mid s)/\partial\theta_{s,b}=\mathbf 1[a=b]-\pi(b\mid s); for a Gaussian with mean μθ(s)\mu_\theta(s) and fixed σ\sigma, a−μθ(s)σ2∇θμθ(s)\frac{a-\mu_\theta(s)}{\sigma^2}\nabla_\theta\mu_\theta(s). REINFORCE (Williams, 1992) samples whole episodes and follows the estimate:

text
input: policy π_θ, value estimate V_w, step sizes α_θ and α_w
repeat for each episode:
    generate S_0, A_0, R_1, …, S_{T−1}, A_{T−1}, R_T by following π_θ
    for t = 0, 1, …, T−1:
        G ← R_{t+1} + γ·R_{t+2} + … + γ^{T−t−1}·R_T      # return from step t
        δ ← G − V_w(S_t)                                  # advantage estimate
        w ← w + α_w · δ · ∇V_w(S_t)                       # fit the baseline
        θ ← θ + α_θ · γ^t · δ · ∇log π_θ(A_t | S_t)        # policy step

REINFORCE with a learned baseline VwV_w (next step). With Vw≡0V_w\equiv0 it is plain REINFORCE. Implementations usually drop the factor γt\gamma^t, which biases the estimate; the Deep Layer lesson discusses what is then being optimized.

Check your understanding

REINFORCE estimates ∇J\nabla J from sampled episodes without knowing the transition probabilities P(s′∣s,a)P(s'\mid s,a). Why is that possible?

  1. Because it learns a model of PP from the episodes first
  2. Because ∇θlog⁡pθ(τ)\nabla_\theta\log p_\theta(\tau) contains only policy terms: the transition probabilities do not depend on θ\theta
  3. Because it assumes deterministic transitions
  4. Because the critic VwV_w replaces the dynamics
Show the answer

B. Because ∇θlog⁡pθ(τ)\nabla_\theta\log p_\theta(\tau) contains only policy terms: the transition probabilities do not depend on θ\theta

The log of a trajectory's probability is a sum of start, policy and transition terms. Differentiating with respect to θ\theta kills every term except ∑tlog⁡πθ(at∣st)\sum_t\log\pi_\theta(a_t\mid s_t). The dynamics still shape the gradient, through which states and returns are sampled, but they never need to be written down.

Baselines and variance

REINFORCE is unbiased but noisy: GtG_t sums many random rewards, and with all-positive rewards every sampled action is pushed up, the better ones only a little more than the worse. The fix is to compare each return with a baseline b(st)b(s_t) and use Gt−b(st)G_t-b(s_t) instead.

DerivationBaselines are free, and the best constant one
  1. Ea∼πθ(⋅∣s)[b(s) ∇θlog⁡πθ(a∣s)]=b(s)∑a∇θπθ(a∣s)=b(s) ∇θ∑aπθ(a∣s)=0\E_{a\sim\pi_\theta(\cdot\mid s)}\big[b(s)\,\nabla_\theta\log\pi_\theta(a\mid s)\big]=b(s)\sum_a\nabla_\theta\pi_\theta(a\mid s)=b(s)\,\nabla_\theta\sum_a\pi_\theta(a\mid s)=0

    A baseline that does not depend on the action leaves the expected gradient unchanged:

  2. ddb E[g2(G−b)2]=−2 E[g2(G−b)]=0⟹b∗=E[g2G]E[g2]\frac{d}{db}\,\E\big[g^2(G-b)^2\big]=-2\,\E\big[g^2(G-b)\big]=0\quad\Longrightarrow\quad b^*=\frac{\E[g^2G]}{\E[g^2]}

    So for one component g=∂log⁡πθ/∂θig=\partial\log\pi_\theta/\partial\theta_i of the score, the estimate g (G−b)g\,(G-b) has a mean that does not depend on bb, and its variance depends on bb only through the second moment. Minimize that:

  3. Aπ(s,a)=Qπ(s,a)−Vπ(s),∇θJ=∑sηγ(s)∑aAπ(s,a) ∇θπθ(a∣s)A^\pi(s,a)=Q^\pi(s,a)-V^\pi(s),\qquad\nabla_\theta J=\sum_s\eta_\gamma(s)\sum_aA^\pi(s,a)\,\nabla_\theta\pi_\theta(a\mid s)

    The variance-optimal constant baseline is an average of returns weighted by the squared score. In practice a learned state value b(s)≈Vπ(s)b(s)\approx V^\pi(s) is the standard choice: simple, often close to optimal, and it turns the return into an estimate of the advantage, how much better the action was than the policy's average:

Check your understanding

A two-armed bandit pays exactly 10 on arm 1 and 11 on arm 2. A softmax policy with one parameter θ\theta, the logit of arm 2, picks each arm with probability 12\tfrac12, so the score ∂log⁡π/∂θ\partial\log\pi/\partial\theta is +12+\tfrac12 for arm 2 and −12-\tfrac12 for arm 1. Without a baseline, single-sample gradient estimates are −5-5 or +5.5+5.5 (mean 0.25, standard deviation 5.25). What is their variance with the baseline b=10.5b=10.5?

  1. About 27.6, unchanged: a baseline cannot change the variance
  2. 0.0625
  3. About 5.25
  4. 0
Show the answer

D. 0

Both samples become +0.25+0.25: (10−10.5)(−12)=(11−10.5)(12)=0.25(10-10.5)(-\tfrac12)=(11-10.5)(\tfrac12)=0.25. Every sample now points the right way with the right size. Here b=10.5b=10.5 is exactly the optimal baseline, since g2=14g^2=\tfrac14 for both arms makes b∗=E[G]b^*=\E[G]. Without it, telling the sign of a 0.25 signal through noise of 5.25 takes about (5.25/0.25)2≈440(5.25/0.25)^2\approx440 samples.

Actor–critic: a learned critic, bootstrapped

REINFORCE with a baseline still waits for the end of each episode to compute GtG_t. An actor–critic bootstraps instead: it replaces the return by the one-step target and uses the TD error of a learned critic VwV_w as its advantage estimate. If the critic were exact, the TD error would be an unbiased estimate of the advantage:

δt=rt+1+γVw(st+1)−Vw(st),E[δt ∣ st,at]=Qπ(st,at)−Vπ(st)=Aπ(st,at)if Vw=Vπ\delta_t=r_{t+1}+\gamma V_w(s_{t+1})-V_w(s_t),\qquad\E\big[\delta_t\,\big|\,s_t,a_t\big]=Q^\pi(s_t,a_t)-V^\pi(s_t)=A^\pi(s_t,a_t)\quad\text{if }V_w=V^\pi
With an imperfect critic the estimate is biased, but far less noisy than Gt−Vw(st)G_t-V_w(s_t), which carries the randomness of the whole future.
text
input: policy π_θ, critic V_w, step sizes α_θ and α_w
repeat for each episode:
    S ← initial state;  I ← 1
    while S is not terminal:
        A ~ π_θ(· | S);  take A, observe R and S'
        δ ← R + γ·V_w(S') − V_w(S)              # V_w(terminal) = 0
        w ← w + α_w · δ · ∇V_w(S)               # critic: TD(0)
        θ ← θ + α_θ · I · δ · ∇log π_θ(A | S)    # actor: advantage-weighted score
        I ← γ·I;  S ← S'

One-step actor–critic (Sutton & Barto, §13.5). The critic usually learns faster than the actor, so that the actor follows a critic that is nearly up to date; two-timescale analyses prove convergence for linear critics of a special, "compatible" form (Konda & Tsitsiklis, 2000).

Actor–critic is an instance of generalized policy iteration: the critic evaluates the current policy, the actor improves it, and neither waits for the other to finish. Policy iteration, from Decisions: Utility, MDPs & Bandits, is the extreme case: an exact evaluation, then a greedy switch in every state. The policy-gradient theorem says the actor's step moves probability toward actions with positive advantage, the same direction as the greedy switch, only a small way.

Think first Policy iteration switches every state to its greedy action at once. Why does an actor–critic take small gradient steps instead?

Its critic is an estimate learned from samples, so a greedy switch would act on the critic's errors at full strength, and the next data would come from that possibly bad policy. With function approximation, changing parameters to fix one state changes the policy in others, so greedy switches can oscillate. With continuous actions the argmax is itself an optimization problem. And small steps keep the policy stochastic, so it keeps exploring. The price is many more rounds; Trust Regions: TRPO & PPO asks how large a step is safe.

Generalized advantage estimation, and the modern family

Between the one-step TD error and the full return lie the nn-step advantages. Their TD errors telescope, which gives a simple way to mix them all, generalized advantage estimation (GAE; Schulman et al., 2016):

Derivationn-step advantages telescope into GAE
  1. A^t(n)=∑l=0n−1γlrt+l+1+γnV(st+n)−V(st)=∑l=0n−1γl δt+l\hat A^{(n)}_t=\sum_{l=0}^{n-1}\gamma^lr_{t+l+1}+\gamma^nV(s_{t+n})-V(s_t)=\sum_{l=0}^{n-1}\gamma^l\,\delta_{t+l}

    The nn-step advantage estimate uses nn real rewards, then the critic. Adding and subtracting γlV(st+l)\gamma^lV(s_{t+l}) for each intermediate step turns it into a sum of TD errors:

  2. A^tGAE(γ,λ)=(1−λ)∑n≥1λn−1A^t(n)=∑l≥0(γλ)l δt+l\hat A^{\mathrm{GAE}(\gamma,\lambda)}_t=(1-\lambda)\sum_{n\ge1}\lambda^{n-1}\hat A^{(n)}_t=\sum_{l\ge0}(\gamma\lambda)^l\,\delta_{t+l}

    Average the nn-step estimates with geometric weights (1−λ)λn−1(1-\lambda)\lambda^{n-1}, as the λ\lambda-return does for values. Each δt+l\delta_{t+l} appears in every estimate with n>ln>l, and those weights sum to λl\lambda^l:

  3. λ=0\lambda=0 gives the TD error: low variance, biased by the critic. λ=1\lambda=1 gives Gt−V(st)G_t-V(s_t): an unbiased gradient for any critic, and the noisiest. Values around 0.9–0.99 are typical, and GAE paired with PPO is a common default.

python
import numpy as np

def gae(rewards, values, dones, gamma=0.99, lam=0.95):
    """rewards[t], dones[t] for t < T; values[t] for t <= T (values[T] bootstraps)."""
    T = len(rewards)
    adv = np.zeros(T)
    running = 0.0
    for t in reversed(range(T)):
        live = 1.0 - dones[t]              # 0 if the episode ended after step t
        delta = rewards[t] + gamma * values[t + 1] * live - values[t]
        running = delta + gamma * lam * live * running
        adv[t] = running
    returns = adv + values[:T]             # regression targets for the critic
    return adv, returns

GAE in one backward pass, using the recursion A^t=δt+γλA^t+1\hat A_t=\delta_t+\gamma\lambda\hat A_{t+1} and resetting at episode boundaries; values is a NumPy array of length T+1T+1.

MethodDataActionsKey idea
A2C / A3C (Mnih et al., 2016)on-policydiscrete or continuousnn-step advantages, entropy bonus, parallel workers instead of replay
TRPO (2015), PPO (2017)on-policydiscrete or continuouslimit how far each update moves the policy
DDPG (2016), TD3 (2018)off-policy, replaycontinuousdeterministic actor following the critic's action gradient
SAC (2018)off-policy, replaymainly continuousmaximum-entropy objective and soft Bellman backups
All are actor–critics. On-policy methods are simpler and more stable; off-policy methods reuse data and are far more sample-efficient, at the cost of the instabilities discussed in Temporal-Difference Learning & Q-Learning.

Key takeaways

  • Policy-based methods do gradient ascent on J(θ)J(\theta) for a parameterized stochastic policy, which suits continuous actions and problems whose best policy is random, like the switched corridor with p∗=2−2p^*=2-\sqrt2.
  • Policy-gradient theorem: ∇J=E[∑tγtGt∇log⁡πθ(at∣st)]=∑sηγ(s)∑aQπ(s,a)∇πθ(a∣s)\nabla J=\E\big[\sum_t\gamma^tG_t\nabla\log\pi_\theta(a_t\mid s_t)\big]=\sum_s\eta_\gamma(s)\sum_aQ^\pi(s,a)\nabla\pi_\theta(a\mid s); the dynamics drop out, and the state distribution is never differentiated.
  • Baselines leave the gradient unbiased because the score has mean zero; the variance-optimal constant is E[g2G]/E[g2]\E[g^2G]/\E[g^2], and a learned Vπ(s)V^\pi(s) turns returns into advantages.
  • Actor–critic uses the TD error as an advantage estimate, trading variance for bias; it is generalized policy iteration with gradient steps in place of greedy switches.
  • GAE, A^t=∑l(γλ)lδt+l\hat A_t=\sum_l(\gamma\lambda)^l\delta_{t+l}, slides from the TD error (λ=0\lambda=0) to the Monte Carlo advantage (λ=1\lambda=1) and feeds A2C, PPO and their relatives.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

Which of these "baselines" would bias the policy-gradient estimate?

  1. A constant
  2. A learned state value Vw(st)V_w(s_t)
  3. The average return of the last 100 episodes
  4. A learned action value Qw(st,at)Q_w(s_t,a_t) of the action actually taken
Show the answer

D. A learned action value Qw(st,at)Q_w(s_t,a_t) of the action actually taken

A baseline may depend on anything except the action it multiplies, because then Ea[b ∇log⁡π(a∣s)]=b∑a∇π(a∣s)=0\E_a[b\,\nabla\log\pi(a\mid s)]=b\sum_a\nabla\pi(a\mid s)=0. Subtracting Qw(st,at)Q_w(s_t,a_t) correlates the baseline with the action, and the expectation no longer vanishes. (Action-dependent control variates can be used, but only with a correction term that restores unbiasedness.)

Question 2

A tabular softmax policy samples action aa in state ss, and the advantage estimate is positive. After one policy-gradient update, what happens to the probabilities of the other actions in ss?

  1. They decrease
  2. They are unchanged, since only θs,a\theta_{s,a} is updated
  3. They increase
  4. They change only if their own advantages were estimated
Show the answer

A. They decrease

The score's component for logit θs,b\theta_{s,b} is 1[a=b]−π(b∣s)\mathbf 1[a=b]-\pi(b\mid s): the sampled action's logit rises by αA^(1−π(a∣s))\alpha\hat A(1-\pi(a\mid s)) and every other logit falls by αA^ π(b∣s)\alpha\hat A\,\pi(b\mid s). Probabilities sum to 1, so raising one lowers the rest.

Question 3

Generalized advantage estimation with λ=0\lambda=0 uses which advantage estimate?

  1. The Monte Carlo return minus the baseline, Gt−V(st)G_t-V(s_t)
  2. The average of all nn-step advantages with equal weights
  3. The one-step TD error δt=rt+1+γV(st+1)−V(st)\delta_t=r_{t+1}+\gamma V(s_{t+1})-V(s_t)
  4. The action value Q(st,at)Q(s_t,a_t)
Show the answer

C. The one-step TD error δt=rt+1+γV(st+1)−V(st)\delta_t=r_{t+1}+\gamma V(s_{t+1})-V(s_t)

A^t=∑l(γλ)lδt+l\hat A_t=\sum_l(\gamma\lambda)^l\delta_{t+l} keeps only l=0l=0 when λ=0\lambda=0: lowest variance, biased by the critic's errors. λ=1\lambda=1 gives Gt−V(st)G_t-V(s_t), which yields an unbiased gradient for any VV but is the noisiest.

Question 4

In the switched-action corridor, why can't an ε-greedy policy over learned action values reach the optimum p∗≈0.59p^*\approx0.59?

  1. Because Q-learning diverges in this problem
  2. Because ε-greedy can only choose right with probability 1−ε/21-\varepsilon/2 or ε/2\varepsilon/2, never an intermediate value
  3. Because the rewards are negative
  4. Because the optimal policy is deterministic and ε-greedy keeps exploring
Show the answer

B. Because ε-greedy can only choose right with probability 1−ε/21-\varepsilon/2 or ε/2\varepsilon/2, never an intermediate value

All cells look alike, so the greedy action is the same everywhere, and ε-greedy can express only p=0.95p=0.95 or p=0.05p=0.05 (for ε=0.1\varepsilon=0.1), worth about −44-44 and −82-82 against −11.7-11.7 at p∗p^*. A parameterized policy can learn any pp.

Question 5

An actor–critic replaces the Monte Carlo return GtG_t in the policy update with the TD target rt+1+γVw(st+1)r_{t+1}+\gamma V_w(s_{t+1}). What is the effect?

  1. No effect on bias or variance
  2. Higher variance, but no bias
  3. It makes the method off-policy
  4. Lower variance, at the price of bias whenever Vw≠VπV_w\neq V^\pi
Show the answer

D. Lower variance, at the price of bias whenever Vw≠VπV_w\neq V^\pi

The TD target depends on one reward and one transition instead of a whole future, so it varies much less. But it trusts VwV_w: if the critic is wrong, the advantage estimate δt\delta_t is wrong in expectation. GAE's λ\lambda chooses a point between the two extremes.

Go deeper

Further reading

  • R. J. Williams, "Simple statistical gradient-following algorithms for connectionist reinforcement learning," Machine Learning 8, 229–256 (1992).
  • R. S. Sutton, D. McAllester, S. Singh & Y. Mansour, "Policy gradient methods for reinforcement learning with function approximation," NeurIPS 12 (2000).
  • J. Schulman, P. Moritz, S. Levine, M. I. Jordan & P. Abbeel, "High-dimensional continuous control using generalized advantage estimation," ICLR (2016).
  • R. S. Sutton & A. G. Barto, Reinforcement Learning: An Introduction, ch. 13 (MIT Press, 2nd ed., 2018).