IE437 · Data-Driven Decision Making and Control — Lecture 10

Policy-Based Reinforcement Learning

Optimal control with the dynamics replaced by data
Jinkyoo Park · KAIST
Lecture 9 derived feedback from a model; this lecture learns a feedback policy from experience.
Policy-Based Reinforcement LearningLecture 10

Where we are — the control lineage, made data-driven

Previous step This chapter's question
Lecture 9 computed feedback from a specified dynamics model. Now improve a parameterized policy using experience.

Values and policies work together in actor–critic methods. A learned actor supplies actions; its training objective and data determine how it improves.

Compute a policy-gradient step, a TD3 target and an entropy-regularized choice.
Lecture 10 · Policy-Based Reinforcement Learning2 / 61
Policy-Based Reinforcement LearningLecture 10

Learning route — make a good action more likely

Bring: Log derivatives, expectations, Bellman targets and feedback.

First pass What to do
Follow the idea REINFORCE → baseline/critic → DDPG/TD3 → SAC → compare PPO
Work without the solution Compute a policy-gradient step, a TD3 target and an entropy-regularized choice.
Return later Full policy-gradient/Fisher derivations, GAE details and multi-agent extensions are references.
For the temperature thread: predict → calculate → reveal and check → change one condition. Complete the core calculation before reading the research extensions.
Lecture 10 · Policy-Based Reinforcement Learning3 / 61
Act 1

A gradient without the model

Q1. The thing we must differentiate is an expectation over trajectories, and the dynamics are inside it.
ACT 1A gradient without the modelLecture 10

The objective, and a gradient we cannot see

Q1 Gradient?Q2 Variance?Q3 Continuous?Q4 Safe step?

Parameterise a stochastic policy πθ(a∣s)\pi_\theta(a\mid s) and maximise the expected return:

J(θ)=Eτ∼πθ[R(τ)],θ←θ+α ∇θJ(θ)J(\theta) = \E_{\tau\sim\pi_\theta}\big[R(\tau)\big], \qquad \theta \leftarrow \theta + \alpha\,\nabla_\theta J(\theta)

The trouble is where the parameter lives. It is not in the integrand; it is in the distribution being integrated against, and that distribution contains the dynamics:

pθ(τ)=μ(s0)∏t=0T−1πθ(at∣st) P(st+1∣st,at)p_\theta(\tau) = \mu(s_0)\prod_{t=0}^{T-1} \pi_\theta(a_t\mid s_t)\,\hl{P(s_{t+1}\mid s_t,a_t)}
The naive answer, and why it is not enoughthe source deck's own first attempt

Perturb one coordinate at a time and difference:   ∂J/∂θk≈(J(θ+ϵuk)−J(θ))/ϵ\;\partial J/\partial\theta_k \approx \big(J(\theta+\epsilon u_k)-J(\theta)\big)/\epsilon. It can estimate local changes even without an analytic derivative — and it costs one full batch of rollouts per parameter. For a large network, coordinatewise finite differences are prohibitively expensive; random-direction methods offer a different trade-off.

Lecture 10 · Policy-Based Reinforcement Learning5 / 61
ACT 1A gradient without the modelLecture 10

The score-function trick — the dynamics vanish

One identity does all the work:   ∇p=p ∇log⁡p\;\nabla p = p\,\nabla \log p. It turns the gradient of an expectation into an expectation of a gradient:

∇θEτ∼pθ[R(τ)]=∫∇θpθ(τ)R(τ) dτ=∫pθ(τ) ∇θlog⁡pθ(τ) R(τ) dτ=Eτ∼pθ[∇θlog⁡pθ(τ) R(τ)]\nabla_\theta \E_{\tau\sim p_\theta}[R(\tau)] = \int \nabla_\theta p_\theta(\tau)R(\tau)\,d\tau = \int p_\theta(\tau)\,\nabla_\theta \log p_\theta(\tau)\,R(\tau)\,d\tau = \E_{\tau\sim p_\theta}\big[\nabla_\theta\log p_\theta(\tau)\,R(\tau)\big]

Now expand that log. The product becomes a sum, and every term without θ\theta differentiates to zero:

∇θlog⁡pθ(τ)=∇θlog⁡μ(s0)⏟= 0+∑t∇θlog⁡πθ(at∣st)+∑t∇θlog⁡P(st+1∣st,at)⏟= 0  =  ∑t∇θlog⁡πθ(at∣st)\nabla_\theta\log p_\theta(\tau) = \underbrace{\nabla_\theta\log\mu(s_0)}_{=\,0} + \sum_t \nabla_\theta\log\pi_\theta(a_t\mid s_t) + \underbrace{\sum_t\nabla_\theta\log \hl{P(s_{t+1}\mid s_t,a_t)}}_{=\,0} \;=\; \sum_{t}\nabla_\theta\log\pi_\theta(a_t\mid s_t)
Their log-density derivatives are zero when they do not directly depend on θ\theta. They still affect which trajectories occur and therefore the expected gradient.

This is the precise sense in which ff is "deleted": we never needed it. Where Lecture 9 solved the dynamics, here they simply drop out of the algebra — the policy's own log-probability is all that is left. We still live in the dynamics; we just never differentiate through them.

Lecture 10 · Policy-Based Reinforcement Learning6 / 61
ACT 1A gradient without the modelLecture 10

Reading the estimator — it is weighted maximum likelihood

Put the two halves together and the whole of Act 1 is one line:

∇θJ(θ)=Eτ∼πθ[(∑t∇θlog⁡πθ(at∣st))⏟∇θJML(θ)  −  make this trajectory likelier (∑trt+1)⏟how good it was]\nabla_\theta J(\theta) = \E_{\tau\sim\pi_\theta}\Big[\underbrace{\Big(\textstyle\sum_t \nabla_\theta\log\pi_\theta(a_t\mid s_t)\Big)}_{\hl{\nabla_\theta J_{\mathrm{ML}}(\theta)} \;-\; \text{make this trajectory likelier}}\ \underbrace{\Big(\textstyle\sum_t r_{t+1}\Big)}_{\text{how good it was}}\Big]

The first factor, alone, is the gradient of the log-likelihood of the trajectory — the maximum-likelihood gradient of Lecture 2, the direction that would make this trajectory more probable. The return simply weights it.

  • Increase the likelihood of trajectories with large accumulated reward;
  • decrease likelihood for negative weights. A small positive return still has a positive weight; a baseline lets us compare with typical performance.
Policy gradient is imitation of your own better moments, reweighted by how well they went.

There is no arg max⁡\argmax anywhere in that sentence, and no model. It is also, exactly, Lecture 6's move — a generative model trained to emit the good samples — one axis over.

Lecture 10 · Policy-Based Reinforcement Learning7 / 61
ACT 1A gradient without the modelLecture 10

The policy gradient theorem, and REINFORCE

For J(θ)=E[∑t=0T−1γtrt+1]J(\theta)=\E[\sum_{t=0}^{T-1}\gamma^t r_{t+1}], define Gt=∑k=tT−1γk−trk+1G_t=\sum_{k=t}^{T-1}\gamma^{k-t}r_{k+1}. Then

∇θJ=E[∑t=0T−1γt∇θlog⁡πθ(at∣st) Gt].\nabla_\theta J=\E\Big[\sum_{t=0}^{T-1}\gamma^t\nabla_\theta\log\pi_\theta(a_t\mid s_t)\,G_t\Big].

REINFORCE: sample complete episodes under the current policy, average this expression, and take a gradient-ascent step. The full-return estimator is unbiased under the usual differentiation and integrability assumptions.

Use one score × its future return per action. For the undiscounted episodic examples below, γ=1\gamma=1. Dropping γt\gamma^t while claiming the same discounted objective is generally incorrect.

The equivalent QπQ^\pi theorem averages over the policy's state visitation weights. The appendix makes those weights explicit.

Lecture 10 · Policy-Based Reinforcement Learning8 / 61
ACT 1A gradient without the modelLecture 10

One policy parameter — see the update direction

A one-step problem has actions A and B. Let πθ(A)=p=sigmoid⁡(θ)=0.5\pi_\theta(A)=p=\operatorname{sigmoid}(\theta)=0.5. Then the log-probability derivatives are 1−p=0.51-p=0.5 for A and −p=−0.5-p=-0.5 for B.

With step size 0.1 and baseline 2:

observed action reward advantage gradient contribution parameter change
A 3 1 0.5(1)=0.50.5(1)=0.5 +0.05
B 1 −1 (−0.5)(−1)=0.5(-0.5)(-1)=0.5 +0.05
Both observations increase the probability of A: A performed above the baseline; B performed below it. The sign comes from both the score and the advantage.
Lecture 10 · Policy-Based Reinforcement Learning9 / 61
ACT 1A gradient without the modelLecture 10

REINFORCE, run — and what it converges toa scalar linear system, learned blind

xt+1=xt+utx_{t+1}=x_t+u_t with cost ∑(x2+u2)\sum(x^2+u^2) — Lecture 9's problem, scalar. The policy is u=−kx+σεu=-kx+\sigma\varepsilon and the only parameter is the gain kk. REINFORCE never sees AA or BB; it only samples. The grey bowl J(k)J(k) and the dashed line k⋆=0.618k^\star = 0.618, the Riccati gain, are drawn for us, not for the agent — and that is where the gain walks to. Read the two numbers on the right: the estimate scatters around the true gradient, never away from it, and its spread falls like 1/N1/\sqrt{N}. Then set the batch to 8 and watch the gain stop settling — that residual wander is Act 2's subject.
Lecture 10 · Policy-Based Reinforcement Learning10 / 61
ACT 1A gradient without the modelLecture 10

Check — why differentiate the policy at all

Value-based RL picks actions by arg max⁡aQ(s,a)\argmax_a Q(s,a). Why does that break down in continuous control?

A table lookup over four actions is free; a maximisation over a continuous vector is an inner optimisation problem, and it recurs at every timestep of every episode. Policy-based methods sidestep it by storing the answer: a parameterised πθ(s)\pi_\theta(s) that outputs the action directly. That is the same forward/inverse move as Lectures 5 and 6, now in a sequential setting.

Lecture 10 · Policy-Based Reinforcement Learning11 / 61
Act 2

Taming variance with a critic

Q2. How can we reduce noise? Reward-to-go and action-independent baselines preserve the expected gradient; bootstrapping with an approximate critic can introduce bias.
ACT 2Taming variance with a criticLecture 10

Why the estimate is so noisy

Q1 Gradient?Q2 Variance?Q3 Continuous?Q4 Safe step?

Look again at what one episode contributes:

g^(i)=(∑t=0T−1∇θlog⁡πθ(at∣st))(∑t=0T−1rt+1)\hat g^{(i)} = \Big(\sum_{t=0}^{T-1}\nabla_\theta\log\pi_\theta(a_t\mid s_t)\Big)\Big(\sum_{t=0}^{T-1} r_{t+1}\Big)

Every score term is multiplied by the same scalar — the whole episode's return. One unlucky tail rescales all TT of them together. And the return itself is a sum of TT random rewards along a random trajectory.

Worse, it is credit assignment by superstition: an action at t=40t=40 is given credit for a reward already received at t=1t=1, which it could not have caused.

Three corrections follow, and the first two preserve the mean; a bootstrapped critic adds an accuracy–variance trade-off.

Keep the distinction clear: subtracting a fixed state baseline from a Monte Carlo return is not the same operation as replacing the return with a learned TD target.

Lecture 10 · Policy-Based Reinforcement Learning13 / 61
ACT 2Taming variance with a criticLecture 10

Fix 1 — causality: half the terms were pure noise

An action at time tt cannot affect a reward at time t′<tt' < t. So those cross-terms have mean zero and contribute nothing but variance. Drop them:

∇θJ=E[∑t∇θlog⁡πθ(at∣st) ∑k=tT−1rk+1]  =  E[∑t∇θlog⁡πθ(at∣st)  Q^t]\nabla_\theta J = \E\Big[\sum_{t}\nabla_\theta\log\pi_\theta(a_t\mid s_t)\ \hl{\sum_{k=t}^{T-1}r_{k+1}}\Big] \;=\; \E\Big[\sum_t \nabla_\theta\log\pi_\theta(a_t\mid s_t)\;\hat Q_t\Big]

For an on-policy rollout continued to termination (or including the full discounted future), the inner sum is the reward-to-go Q^t\hat Q_t, an unbiased sample of Qπ(st,at)Q^\pi(s_t,a_t). A truncated or bootstrapped return needs a separate bias analysis.

The cost of this fix is one index. It is the cheapest variance reduction in reinforcement learning, and in the numbers of the Act 1 widget it removes about half.

Lecture 10 · Policy-Based Reinforcement Learning14 / 61
ACT 2Taming variance with a criticLecture 10

Fix 2 — a baseline: subtract anything action-independent

Subtract from each reward-to-go a quantity b(st)b(s_t) that does not depend on the action taken:

∇θJ=E[∑t∇θlog⁡πθ(at∣st)(Q^t−b(st))]\nabla_\theta J = \E\Big[\sum_t \nabla_\theta\log\pi_\theta(a_t\mid s_t)\big(\hat Q_t - b(s_t)\big)\Big]
The baseline is freeit adds exactly zero bias
Ea∼πθ[∇θlog⁡πθ(a∣s) b(s)]=b(s)∫∇θπθ(a∣s)πθ(a∣s)πθ(a∣s) da=b(s) ∇θ ⁣∫ ⁣πθ(a∣s) da=b(s) ∇θ1=0\E_{a\sim\pi_\theta}\big[\nabla_\theta\log\pi_\theta(a\mid s)\,b(s)\big] = b(s)\int \frac{\nabla_\theta \pi_\theta(a\mid s)}{\pi_\theta(a\mid s)}\pi_\theta(a\mid s)\,da = b(s)\,\nabla_\theta\!\int\!\pi_\theta(a\mid s)\,da = b(s)\,\nabla_\theta 1 = 0

A useful baseline is b(s)=Vπ(s)=E[Gt∣st=s]b(s)=V^\pi(s)=\E[G_t\mid s_t=s]. It predicts the return typical of this state, so Gt−b(s)G_t-b(s) asks whether the action did better than expected.

The value baseline is practical, but not always the exact minimum-variance baseline: the latter also weights by the squared score magnitude. A poorly chosen baseline can increase variance.

Treat the baseline as fixed in the actor gradient. Training it on independent or previously collected data avoids the extra dependence created by fitting and evaluating on the same action sample. The exact weighted formula is in Backup 3.

Lecture 10 · Policy-Based Reinforcement Learning15 / 61
ACT 2Taming variance with a criticLecture 10

Temperature thread — make the better heater action more likelyshared teaching example · predict before revealing the calculation

For two actions, let Q(off)=−6.7Q(\mathrm{off})=-6.7 and Q(heat)=−2.9Q(\mathrm{heat})=-2.9. The policy heats with p=σ(θ)p=\sigma(\theta). At θ = 0, p = 0.5 and dp/dθ=0.25dp/d\theta=0.25. Treat the Q estimates as fixed for this actor step.

Predict: Which way should θ move? Does the fact that both action values are negative change the preferred direction?

Calculate and check. J=(1−p)(−6.7)+p(−2.9)J=(1-p)(-6.7)+p(-2.9), so dJ/dθ=0.25[−2.9−(−6.7)]=0.95dJ/d\theta=0.25[-2.9-(-6.7)]=\mathbf{0.95}. Gradient ascent raises θ and makes heating more likely. The current value baseline is −4.8.

Relative action quality determines this update. A useful action can have a negative return when every outcome has a cost.
Lecture 10 · Policy-Based Reinforcement Learning16 / 61
ACT 2Taming variance with a criticLecture 10

Try it — both action values shift down by 100work independently · reveal only after writing an answer

Change the fixed Q estimates to −106.7 and −102.9. Keep the same policy parameter. Recalculate the actor gradient and the value baseline.

Check your answer. The difference remains 3.8, so the gradient remains 0.95. The baseline becomes −104.8. Subtracting that state-only baseline leaves the advantages unchanged.

A common offset changes the reported value but not this policy preference. Baseline invariance requires an action-independent subtraction.
Lecture 10 · Policy-Based Reinforcement Learning17 / 61
ACT 2Taming variance with a criticLecture 10

The baseline, measured

The same task, the same seed, the same starting gain, ten episodes per update — the only difference is whether b(st)b(s_t) is subtracted. Left: the gain over 100 updates. Right: the variance of the per-episode gradient, on a log axis. The baseline changes the mean of the estimator not at all and its spread by nearly twenty-fold, which is the difference between a run that settles on k⋆k^\star and one that keeps wandering past it.
Lecture 10 · Policy-Based Reinforcement Learning18 / 61
ACT 2Taming variance with a criticLecture 10

Fix 3 — the advantage, and the actor–critic

Put the two together. With b(s)=Vπ(s)b(s)=V^\pi(s) and Q^t→Qπ(st,at)\hat Q_t \to Q^\pi(s_t,a_t), what multiplies the score is the advantage:

Aπ(s,a)=Qπ(s,a)−Vπ(s)— "how much better than average was this action?"A^\pi(s,a) = Q^\pi(s,a) - V^\pi(s) \qquad\text{— "how much better than average was this action?"}

And now we need a learned VV. Learn both:

Actor πθ(a∣s)\pi_\theta(a\mid s)steps θ\theta along ∇θlog⁡πθ⋅A^\nabla_\theta\log\pi_\theta\cdot\hat A
Critic Vw(s)V_w(s)returns A^=r+γVw(s′)−Vw(s)\hat A = r + \gamma V_w(s') - V_w(s)

That A^\hat A is a TD error — Lecture 8's engine, running inside a policy update. An actor proposes actions and a critic estimates their consequences. Actor–critic methods combine policy optimization with value estimation; the course columns help explain the ingredients, not exclusive origins.

Lecture 10 · Policy-Based Reinforcement Learning19 / 61
ACT 2Taming variance with a criticLecture 10

Baseline versus bootstrap — separate the two operations

Suppose the observed full return is 4.6, the baseline is 2, and the next-state critic is 3. With reward 1 and γ=0.9\gamma=0.9:

signal calculation what it relies on
MC minus baseline 4.6−2=2.64.6-2=2.6 the observed return
one-step TD advantage 1+0.9(3)−2=1.71+0.9(3)-2=1.7 a learned continuation value
A fixed action-independent baseline cancels in expectation. An inaccurate continuation value generally does not. Actor–critic can trade some bias for faster, less noisy updates.

At a true terminal state, continuation value is zero. GAE combines multiple TD errors to control this trade-off.

Lecture 10 · Policy-Based Reinforcement Learning20 / 61
ACT 2Taming variance with a criticLecture 10

Two dials on the same ideawhat the field does with the actor–critic once it has one

  • A3C / A2C — run many actors in parallel on separate copies of the environment. Their rollouts provide more diverse recent experience without a large replay buffer. A2C synchronises updates; A3C permits parameter lag, so neither parallelism nor freshness means exact sample independence. (Mnih et al., 2016)
  • nn-step returns — bootstrap after nn steps rather than at the end:   Rt=∑i=1nγi−1rt+i+γnV(st+n)\;R_t = \sum_{i=1}^{n}\gamma^{i-1}r_{t+i} + \gamma^{n}V(s_{t+n}). A full Monte Carlo return continues to termination with zero bootstrap; one-step actor–critic uses n=1n=1.
  • GAE — do not pick nn; average all of them geometrically,   A^tGAE(γ,λ)=∑l≥0(γλ)l δt+lV\;\hat A_t^{\mathrm{GAE}(\gamma,\lambda)} = \sum_{l\ge0}(\gamma\lambda)^l\,\delta^V_{t+l}. (Schulman et al., 2016)
GAE is TD(λ\lambda) for the advantage — Lecture 8's bias–variance dial, moved from the value to the thing that trains the policy.
Lecture 10 · Policy-Based Reinforcement Learning21 / 61
ACT 2Taming variance with a criticLecture 10

A3C and A2C — collect several short rollouts, then learnoriginal policy-RL PDF pp. 44–47 · parallel collection, not arbitrary replay

Each worker interacts with its own environment copy and forms an nn-step target. For the main lecture's undiscounted episodic convention,

Gt(n)=∑j=0n−1rt+j+1+Vw(st+n),A^t=Gt(n)−Vw(st).G_t^{(n)}=\sum_{j=0}^{n-1}r_{t+j+1}+V_w(s_{t+n}),\qquad \hat A_t=G_t^{(n)}-V_w(s_t).

If an episode terminates within the window, stop the reward sum there and use zero continuation value. Discounted versions retain the corresponding powers of γ\gamma.

Method Coordination
A3C workers apply updates asynchronously; local parameters can lag behind the shared ones
A2C collect a batch from workers, then update synchronously
Parallel workers diversify recent experience. This does not make samples independent or justify uncorrected use of arbitrarily old off-policy data.
Lecture 10 · Policy-Based Reinforcement Learning22 / 61
ACT 2Taming variance with a criticLecture 10

Off-policy policy gradients — correct the distribution you sampledoriginal policy-RL PDF pp. 39–40 · why reusing data needs care

At a fixed state, data from behaviour policy β\beta can estimate an expectation under πθ\pi_\theta using importance ratios:

Ea∼πθ[h(s,a)]=Ea∼β ⁣[πθ(a∣s)β(a∣s)h(s,a)].\mathbb E_{a\sim\pi_\theta}[h(s,a)]=\mathbb E_{a\sim\beta}\!\left[\frac{\pi_\theta(a\mid s)}{\beta(a\mid s)}h(s,a)\right].

This requires β(a∣s)>0\beta(a\mid s)>0 wherever the target policy assigns probability. If π(A∣s)=0.8\pi(A\mid s)=0.8 but β(A∣s)=0.4\beta(A\mid s)=0.4, observed A actions receive weight 2.

That ratio corrects the action distribution at this state. It does not by itself correct which states the behaviour policy visits or give an exact gradient of the original on-policy return. Off-policy actor–critic methods need their own objective and assumptions.
Lecture 10 · Policy-Based Reinforcement Learning23 / 61
ACT 2Taming variance with a criticLecture 10

Check — what a baseline does

REINFORCE's gradient estimate is unbiased but very noisy. Subtracting a state-dependent baseline b(s)b(s) from the return:

The score-function identity gives E[∇log⁡π⋅b(s)]=0\mathbb{E}[\nabla \log \pi \cdot b(s)] = 0 for any bb that does not depend on the action, so subtracting it is free. Choosing b(s)=V(s)b(s) = V(s) turns the return into the advantage — "was this action better than average here?" — which is the signal you actually wanted, and is what makes the actor–critic architecture worth its second network.

Lecture 10 · Policy-Based Reinforcement Learning24 / 61
Act 3

Continuous control: DDPG

Q3. Lecture 8 handed over a wall. This is where it falls.
ACT 3Continuous control: DDPGLecture 10

The wall Lecture 8 left

Q1 Gradient?Q2 Variance?Q3 Continuous?Q4 Safe step?

The source deck states the debt in one sentence: "although DQN solves problems with high-dimensional observation spaces, it can only handle discrete and low-dimensional action spaces". Consider two common choices for using a Q-network with continuous actions.

Option 1 — discretise the action

One output head per action, as in DQN. Take −1≤a≤1-1\le a\le 1 and cut it into bins of width Δa\Delta a.

What is a good Δa\Delta a? Coarse bins mean poor control resolution; fine bins mean ndn^d heads for dd joints. And the optimum may lie between grid points.

Option 2 — feed the action in

One network Qw(s,a)Q_w(s,a) with the action as an input, so the action stays continuous.

But the update needs max⁡a′Qw(s′,a′)\max_{a'}Q_w(s',a'), and QwQ_w is non-convex in a′a'. That is a global optimisation, at every transition, forever.

Discretization changes the action set; generic continuous maximization adds an inner numerical search. Structured critics can make that search easier. Here we pursue a different practical choice: learn an actor that proposes the action, then improve it using the critic.

Lecture 10 · Policy-Based Reinforcement Learning26 / 61
ACT 3Continuous control: DDPGLecture 10

The wall, measured

One state, one continuous action, and the critic's Q(s,⋅)Q(s,\cdot) across it. Nine bins already cost 96=531,4419^6 = 531{,}441 evaluations per transition on a six-joint arm — and still miss the peak by 0.160.16. Twenty-one bins close the gap and cost 85,766,121. The actor emits its action in one forward pass and refines it by following ∇aQ\nabla_a Q: cheap, and only ever local — move its start and watch it settle on the wrong hill, which exposes local optimization. TD3 addresses critic-related errors and SAC changes the objective; neither guarantees finding the best peak.
Lecture 10 · Policy-Based Reinforcement Learning27 / 61
ACT 3Continuous control: DDPGLecture 10

The deterministic fix — the actor climbs the critic

Make the actor deterministic, a=μθ(s)a = \mu_\theta(s), and let it ascend the critic's action-gradient: (Silver et al., 2014)

∇θJ(μθ)=Es∼ρμ[ ∇θμθ(s)  ∇aQ(s,a)∣a=μθ(s)]\nabla_\theta J(\mu_\theta) = \E_{s\sim\rho^\mu}\Big[\,\nabla_\theta \mu_\theta(s)\;\nabla_a Q(s,a)\big|_{a=\mu_\theta(s)}\Big]
This is how the intractable max⁡aQ\max_a Q is finally beaten: the actor follows ∇aQ\nabla_a Q uphill instead of searching for its summit.

Determinism is not a stylistic preference. Compare the Bellman expectation in the two cases:

Qπ(st,at)=Er,s′∼E[r+γ Ea′∼π[Qπ(s′,a′)]]versusQμ(st,at)=Er,s′∼E[r+γ Qμ(s′,μ(s′))]Q^\pi(s_t,a_t) = \E_{r,s'\sim E}\big[r + \gamma\,\hl{\E_{a'\sim\pi}}[Q^\pi(s',a')]\big] \qquad\text{versus}\qquad Q^\mu(s_t,a_t) = \E_{r,s'\sim E}\big[r + \gamma\,Q^\mu(s',\mu(s'))\big]

With a deterministic μ\mu the inner expectation disappears and only the environment is left inside the expectation. Two consequences, both decisive: the critic can use off-policy transitions with adequate coverage, and the actor need not sample an action integral. Arbitrary unsupported data and inaccurate critics do not provide the theorem’s guarantee.

Lecture 10 · Policy-Based Reinforcement Learning28 / 61
ACT 3Continuous control: DDPGLecture 10

DDPG — deterministic policy gradient, plus every DQN stabiliserLillicrap et al., 2015 — DQN (2013) → DPG (2014) → DDPG (2016)

The two losses

Critic, by Bellman error on a replayed minibatch:

yi=ri+γ(1−di) Qw−(si′,μθ−(si′)),L(w)=1N∑i(Qw(si,ai)−yi)2.\begin{aligned} y_i&=r_i+\gamma(1-d_i)\,Q_{w^-}(s_i\prime,\mu_{\theta^-}(s_i\prime)),\\ L(w)&=\frac1N\sum_i\big(Q_w(s_i,a_i)-y_i\big)^2. \end{aligned}

Here si′s_i\prime is the next state stored with sample ii, and did_i indicates true termination. Actor, by the deterministic policy gradient:

∇θJ≈1N∑i∇aQw(si,a)∣a=μθ(si)∇θμθ(si)\nabla_\theta J \approx \frac1N\sum_i \nabla_a Q_w(s_i,a)\big|_{a=\mu_\theta(s_i)}\nabla_\theta\mu_\theta(s_i)

The stabilisers, returning

  • replay buffer — off-policy is now permitted, so use it;
  • target networks w−,θ−w^-,\theta^-, updated softly every step, w−←τw+(1−τ)w−w^-\leftarrow\tau w + (1-\tau)w^-, rather than copied every CC steps;
  • both are Lecture 8's deadly-triad fixes, unchanged. The paper's own verdict on ablating them: "target networks matter a lot".

How the actor gradient appears in code. In code the actor loss is written pi_loss = -Q(s, mu(s)) and .backward() is called; autograd's chain rule ∂θQ(s,μθ(s))=∂aQ⋅∂θμθ\partial_\theta Q(s,\mu_\theta(s)) = \partial_a Q\cdot\partial_\theta\mu_\theta implements the actor’s local chain-rule factor. The theorem also specifies the value function and state visitation distribution; replay-based DDPG uses approximations to them.

Lecture 10 · Policy-Based Reinforcement Learning29 / 61
ACT 3Continuous control: DDPGLecture 10

Follow a critic uphill — a scalar actor calculation

At one state let Q(a)=5−(a−2)2Q(a)=5-(a-2)^2 and let the actor output a=θa=\theta. Initially θ=0\theta=0.

dQda=−2(a−2),dadθ=1.\frac{dQ}{da}=-2(a-2),\qquad\frac{da}{d\theta}=1.

A step of size 0.1 gives θnew=0+0.1(4)=0.4\theta_{\mathrm{new}}=0+0.1(4)=0.4. The critic's score rises from 1 to 2.44.

The actor follows the critic's slope, without differentiating the environment. If the critic is wrong around 0.4, an improved predicted value may still mean worse real performance.
Lecture 10 · Policy-Based Reinforcement Learning30 / 61
ACT 3Continuous control: DDPGLecture 10

μθ(s)\mu_\theta(s) and KK — compare their feedback role

Put Lecture 9's Act 3 and this act side by side. Both produce feedback, using different assumptions and procedures.

LQR (Lecture 9) DDPG (here)
the controller u=−Kxu = -Kx a=μθ(s)a = \mu_\theta(s)
how it is obtained solve the Riccati equation ascend ∇aQ\nabla_a Q from samples
does it need the model? yes — AA, BB, QQ, RR no — sampled transitions
what it is an m×nm\times n matrix a neural network
optimality global under LQR assumptions no general guarantee of a local or global optimum
Same role — a state-to-action feedback rule — but different learning procedures and optimality guarantees.

The Act 1 widget uses a simple LQ benchmark with a known Riccati answer to assess a learned gain. Success on this example illustrates the feedback role; it is not a general convergence guarantee for policy gradients or DDPG.

Lecture 10 · Policy-Based Reinforcement Learning31 / 61
ACT 3Continuous control: DDPGLecture 10

A deterministic actor explores nothing

A deterministic policy has no randomness to explore with, and the obvious repair — act uniformly at random — is a poor one. The source deck gives three reasons, and the third is unusual in this course:

  • random actions drive the policy update into regions where the critic is not accurate (Lecture 5's adversarial-optimiser hazard, in an RL costume);
  • exploring unseen states needs action that is consistent along the episode, not resampled each step;
  • and on real hardware, rapid random input changes can strain actuators.
The pendulum argumentthe source deck's own picture

Swinging a pole upright takes a sustained push in one direction, then alternation near the top. Independent zero-mean noise often cancels across steps and may explore sustained maneuvers inefficiently, so a uniformly random policy might eventually find the swing-up — after enormously many samples.

Hence the Ornstein–Uhlenbeck process,  dxt=−κ xt dt+σ dWt\,dx_t = -\kappa\,x_t\,dt + \sigma\,dW_t, added to μθ(s)\mu_\theta(s): noise that is temporally correlated, so exploration pushes rather than jitters.

Lecture 10 · Policy-Based Reinforcement Learning32 / 61
ACT 3Continuous control: DDPGLecture 10

TD3 — keep the deterministic actor, repair three critic-related failuresFujimoto, van Hoof & Meger · ICML 2018 · Addressing Function Approximation Error in Actor-Critic Methods

A DDPG actor can exploit an erroneously high critic value. TD3 changes the target and update timing. Here dd is the terminal indicator and ϵ\epsilon is zero-mean Gaussian target noise.

Change Operation Purpose
Clipped double Q use the smaller of two target-critic values reduce overly optimistic bootstrap targets
Delayed policy updates update the actor less often than the critics allow critic estimates to improve before the next actor step
Target policy smoothing add clipped noise to the target action average over nearby actions instead of rewarding a narrow spurious peak
a~′=clip⁡(μθ−(s′)+clip⁡(ϵ,−c,c),amin⁡,amax⁡),y=r+γ(1−d)min⁡i=1,2Qwi−(s′,a~′).\begin{aligned} \tilde a'&=\operatorname{clip}\big(\mu_{\theta^-}(s')+\operatorname{clip}(\epsilon,-c,c),a_{\min},a_{\max}\big),\\ y&=r+\gamma(1-d)\min_{i=1,2}Q_{w_i^-}(s',\tilde a'). \end{aligned}
The two critics each regress to this target. On delayed steps the actor climbs the first critic. Target smoothing noise is separate from exploration noise used to collect data. TD3
Lecture 10 · Policy-Based Reinforcement Learning33 / 61
ACT 3Continuous control: DDPGLecture 10

Calculate a TD3 target — and keep its guarantee in proportion

Let r=1r=1, γ=0.9\gamma=0.9, and d=0d=0. A target actor proposes 0.5; the clipped target noise is 0.1, so the smoothed action is 0.6 within the bounds [−1,1][-1,1].

Value at that same next action Estimate
First target critic Qw1−(s′,0.6)=8Q_{w_1^-}(s',0.6)=8
Second target critic Qw2−(s′,0.6)=6Q_{w_2^-}(s',0.6)=6
yTD3=1+0.9min⁡(8,6)=6.4.y_{\rm TD3}=1+0.9\min(8,6)=6.4.

Using the first estimate alone would give 8.2 at this action. If the transition were terminal, both targets would instead be 1. An illustrative delay of two means two critic updates for each actor update.

A smaller target addresses one error mechanism; it is not a certified lower bound on the true return. Critics can share errors. Lecture 12 keeps these TD3 mechanics and adds a behaviour-cloning term for fixed-data learning.
Lecture 10 · Policy-Based Reinforcement Learning34 / 61
ACT 3Continuous control: DDPGLecture 10

SAC — reward good actions while preserving policy entropyHaarnoja et al. · ICML 2018 · an entropy-regularized objective

SAC trains a stochastic actor from replay. Its discounted episodic objective includes policy entropy:

J(π)=Eπ ⁣[∑t=0T−1γt(rt+1+αHH(π(⋅∣st)))].J(\pi)=\mathbb E_\pi\!\left[\sum_{t=0}^{T-1}\gamma^t\big(r_{t+1}+\alpha_H\mathcal H(\pi(\cdot\mid s_t))\big)\right].

Here αH>0\alpha_H>0 is the entropy temperature, not the gradient step size. Consider a one-step, two-action illustration with rewards 2 and 1.8, and αH=0.5\alpha_H=0.5:

Policy Expected reward Entropy, using natural logs Reward + temperature × entropy
Always choose the first action 2 0 2
Choose each with probability 0.5 1.9 log⁡2≈0.693\log2\approx0.693 2.247
The mixture wins between these two candidates because the objective values diversity as well as reward. This discrete illustration explains the entropy term; continuous SAC uses a probability density and differential entropy. Soft Actor-Critic
Lecture 10 · Policy-Based Reinforcement Learning35 / 61
ACT 3Continuous control: DDPGLecture 10

SAC in the learning loop — a soft target and a stochastic actortwin-Q formulation from Soft Actor-Critic Algorithms and Applications · 2018/2019

Draw a next action a′∼πθ(⋅∣s′)a'\sim\pi_\theta(\cdot\mid s') for each replayed transition. Train both critics toward

y=r+γ(1−d)[min⁡i=1,2Qwi−(s′,a′)−αHlog⁡πθ(a′∣s′)].y=r+\gamma(1-d)\left[\min_{i=1,2}Q_{w_i^-}(s',a')-\alpha_H\log\pi_\theta(a'\mid s')\right].

The actor minimizes, over replayed states and newly sampled current-policy actions,

Lπ=Es∼D, a∼πθ[αHlog⁡πθ(a∣s)−min⁡iQwi(s,a)].L_\pi=\mathbb E_{s\sim D,\,a\sim\pi_\theta}\left[\alpha_H\log\pi_\theta(a\mid s)-\min_iQ_{w_i}(s,a)\right].
Replayreuse real transitions for critic fitting
Sample actionsuse the current stochastic actor
Improvetrade critic value against loss of entropy
The actor can use the reparameterization idea from Lecture 6. The original ICML version used a separate value network; these equations are the later twin-Q variant. Neither replay nor entropy fixes missing coverage in a fixed offline log. Algorithms and Applications
Lecture 10 · Policy-Based Reinforcement Learning36 / 61
ACT 3Continuous control: DDPGLecture 10

Check — the deterministic gradient

DDPG trains a critic Q(s,a)Q(s,a) and a deterministic actor μ(s)\mu(s). How does the actor get its gradient?

The critic is a differentiable surrogate for "how good is this action here", so the actor can be moved uphill on it by the chain rule — no action sampling inside this deterministic actor derivative; the state samples still come from data. Notice what has just been re-created: an optimiser climbing a learned model of the objective, which is Lecture 5's setup exactly. Lecture 12 shows it failing in the same way.

Lecture 10 · Policy-Based Reinforcement Learning37 / 61
Act 4

Stepping without falling

Q4. We have a gradient and we have tamed its variance. How far along it dare we step?
ACT 4Stepping without fallingLecture 10

The step-size trap unique to RL

Q1 Gradient?Q2 Variance?Q3 Continuous?Q4 Safe step?

In supervised learning a bad step costs one bad update; the next minibatch arrives from the same fixed dataset and pulls you back. In RL it is worse, because

the policy generates its own next batch of data.

A step that pushes πθ\pi_\theta too far lands in a region where the policy is bad — and now every subsequent sample comes from that bad policy. The gradient estimated there points somewhere else again. The damage is self-reinforcing, and there is no fixed dataset to fall back on.

This is also why the parameter step size is the wrong thing to control. A tiny change in θ\theta can produce a large change in behaviour (a sensitive neural network or a Gaussian policy with very small variance), and a large one can produce none at all. What must be bounded is the distance between the old and new action distributions.

Lecture 10 · Policy-Based Reinforcement Learning39 / 61
ACT 4Stepping without fallingLecture 10

A trust region, in policy space

Maximise an importance-weighted advantage, subject to staying inside a KL ball around the policy that collected the data: (Schulman et al., 2015)

max⁡θ E[πθ(a∣s)πθold(a∣s) A^]s.t.E[DKL(πθold(⋅∣s) ∥ πθ(⋅∣s))]≤δ\max_{\theta}\ \E\Big[\frac{\pi_\theta(a\mid s)}{\pi_{\theta_{\mathrm{old}}}(a\mid s)}\,\hat A\Big] \quad\text{s.t.}\quad \E\big[D_{\mathrm{KL}}\big(\pi_{\theta_{\mathrm{old}}}(\cdot\mid s)\,\|\,\pi_\theta(\cdot\mid s)\big)\big] \le \delta

The ratio reweights old-policy actions. A local linear objective and quadratic KL give the natural-gradient step (Backup 5). Practical average-KL TRPO does not by itself guarantee monotonic real return; the theoretical bound uses stronger assumptions.

This is Lecture 1's trust region, movedthe trust-region widget of Chapter 1, in policy space
Lecture 1 · successive convexification TRPO
a quadratic model of ff a linear model of the advantage
trust radius ρ\rho in parameter space KL radius δ\delta in behaviour space
accept if the model was believable, else shrink backtrack until estimated KL and surrogate improvement pass their checks

Shared idea: restrict an update to where its local model is useful. The metrics and acceptance tests differ.

Lecture 10 · Policy-Based Reinforcement Learning40 / 61
ACT 4Stepping without fallingLecture 10

PPO — discourage large changes with a clipped objective

Practical TRPO approximates a KL-constrained step. PPO uses a simpler surrogate with a similar intent: with r(θ)=πθ(a∣s)/πθold(a∣s)r(\theta) = \pi_\theta(a\mid s)/\pi_{\theta_{\mathrm{old}}}(a\mid s), (Schulman et al., 2017)

JCLIP(θ)=E[min⁡( r(θ) A^,  clip(r(θ), 1−ϵ, 1+ϵ) A^ )]J^{\mathrm{CLIP}}(\theta) = \E\Big[\min\big(\,r(\theta)\,\hat A,\ \ \mathrm{clip}\big(r(\theta),\,1-\epsilon,\,1+\epsilon\big)\,\hat A\,\big)\Big]

No second-order machinery, no conjugate gradient, no line search. When the ratio leaves [1−ϵ,1+ϵ][1-\epsilon,1+\epsilon] in the direction the update was pushing it, the objective goes flat and the incentive to push further is simply removed.

With shared actor–critic parameters the practical objective adds two terms — −c1(Vθ(s)−Vtarget)2-c_1(V_\theta(s)-V_{\text{target}})^2 for the critic and +c2H(πθ(⋅∣s))+c_2 H(\pi_\theta(\cdot\mid s)), an entropy bonus for exploration. The entropy term is the seed of maximum-entropy RL and of SAC.

Lecture 10 · Policy-Based Reinforcement Learning41 / 61
ACT 4Stepping without fallingLecture 10

Calculate the clip — the sign of advantage matters

Let ϵ=0.2\epsilon=0.2. For one sampled action, compare rA^r\hat A with clip⁡(r,0.8,1.2)A^\operatorname{clip}(r,0.8,1.2)\hat A, and keep the smaller number.

advantage ratio ordinary term clipped term PPO term
+2 1.4 2.8 2.4 2.4
−2 0.6 −1.2 −1.6 −1.6
−2 1.4 −2.8 −2.4 −2.8
PPO removes the incentive to increase a good action too much or decrease a bad one too much. It still penalizes making a bad action more likely. Clipping is not a hard bound on every probability ratio or on KL.
Lecture 10 · Policy-Based Reinforcement Learning42 / 61
ACT 4Stepping without fallingLecture 10

The clip, and the asymmetry nobody mentions

The clipped objective as a function of the ratio, for a good action (A^>0\hat A>0) and a bad one (A^<0\hat A<0). Read the slopes: for A^>0\hat A>0 the gradient is exactly zero above 1+ϵ1+\epsilon — no reward for making a good action still likelier. For A^<0\hat A<0 it is zero below 1−ϵ1-\epsilon but stays alive above 1+ϵ1+\epsilon: an action already too probable and known to be bad keeps being pushed down. The clip only removes the incentive that would take you out of the region.
Lecture 10 · Policy-Based Reinforcement Learning43 / 61
ACT 4Stepping without fallingLecture 10

PPO and SAC — compare complete learning proceduresSchulman et al. (2017) · Haarnoja et al. (2018)

Question PPO SAC
Which data? recent rollouts under the collection policy; reused for a limited number of epochs a replay buffer containing transitions from earlier policies
What guides the actor? an estimated advantage with a clipped probability-ratio objective soft Q estimates and an entropy term
What controls the update? clipping changes incentives for probability-ratio changes actor/critic optimization and an entropy temperature
How is exploration represented? stochastic collection policy; an entropy bonus is often added entropy is part of the stated maximum-entropy objective

Both can use stochastic neural policies in continuous control. PPO clipping is not a hard KL guarantee; SAC's replay is not a guarantee that arbitrary offline data will suffice.

Compare return, environment steps and computation under the same evaluation protocol. TD3 is a deterministic off-policy comparison; Lecture 12 removes further interaction. PPO · SAC
Lecture 10 · Policy-Based Reinforcement Learning44 / 61
ACT 4Stepping without fallingLecture 10

Check — why large policy changes are discouraged

PPO discourages some large policy updates through its clipped surrogate. Why are large changes risky?

On-policy data is only evidence about policies near the one that gathered it. A large update leaves that neighbourhood, and the objective being maximised is then a surrogate evaluated well outside its region of validity — Lecture 1's trust region, arrived at from a completely different direction, and the same adversarial-optimiser problem as Lecture 5.

Lecture 10 · Policy-Based Reinforcement Learning45 / 61
CLOSING

Closing

Both lineages have now had the model taken away. The grid is full.
CLOSINGLecture 10

Where we are — both lineages, now data-driven

Lineage A · OR / Dynamic Programming
Lineage B · Control Theory
Model-based
(origin)
MDP & Dynamic ProgrammingLecture 7
Optimal Control / PlanningLecture 9
Data-driven
(extension)
Value-Based RLLecture 8
Policy-Based RLLecture 10

Two traditions, each with a model-based origin and a data-driven extension, and the same move relates each pair:

model-based origin what is deleted data-driven extension
Lineage A · OR MDP & DP (Lec 7) the model (P,R)(P,R) value-based RL (Lec 8)
Lineage B · Control optimal control (Lec 9) the dynamics ff policy-based RL (Lec 10)
One orphaning move, made twice: delete the model, sample instead.
Lecture 10 · Policy-Based Reinforcement Learning47 / 61
CLOSINGLecture 10

What we hand on

Lecture 10 leavesthe trust-region machinery — a KL ball, and a clip
Lecture 11 puts the model backlearned, and lets the two lineages rejoin

Lecture 1 and TRPO both control where a local approximation is trusted, using different metrics and acceptance rules. PPO clipping instead changes incentives in its sampled objective; it does not impose a hard KL bound. Lecture 12 adds another issue: evaluating a changed policy using a fixed log.

Lecture 11 adds a learned model: MBPO uses SAC to learn from short synthetic rollouts, while Dreamer trains an actor and critic in latent imagination. Lecture 12 later starts from TD3 and adds behavior cloning when fresh interaction is unavailable.

Lecture 10 · Policy-Based Reinforcement Learning48 / 61
Policy gradients learn feedback from experience; their guarantees differ from model-based optimal control.
The dynamics never solved, only experienced — and the controller learned, not derived.
Questions?
Lecture 8 learns action values; this lecture learns feedback policies. Explain the policy-gradient estimate first, then distinguish DDPG/TD3's deterministic actor, PPO's clipped update, and SAC's entropy-regularized learning. Their objectives, data and estimators differ. Which learned model could help each one use fewer real interactions?
APPENDIX

Backup slides

Complete arguments, kept out of the narrative.
APPENDIXBackup slidesLecture 10

Reading guide — learn feedback, then test the critic and the data regimeone main idea to explain, one comparison, one application

Role Read or revisit Question to answer
Core Schulman et al., Proximal Policy Optimization Algorithms (2017) How is an advantage estimate used while discouraging large policy changes?
Compare Haarnoja et al., Soft Actor-Critic (ICML 2018); Fujimoto et al., TD3 (ICML 2018) What changes when learning from replay, using twin critics or rewarding entropy?
Apply The scalar feedback benchmark and the TD3/entropy calculations in this lecture Does a better critic score imply a better real controller?
First derive REINFORCE and DDPG. Then compare PPO and SAC as two complete learning procedures. TD3 supplies the prerequisite for Lecture 12's TD3+BC; A3C, GAE and exact trust-region derivations provide supporting context.
Lecture 10 · Policy-Based Reinforcement Learning52 / 61
APPENDIXBackup slidesLecture 10

Backup 1 — the policy gradient theorem, the DP route (i): a recursion

Use a fixed start distribution μ\mu, bounded rewards, and γ<1\gamma<1: J(θ)=∑sμ(s)Vπ(s)J(\theta)=\sum_s\mu(s)V^\pi(s). Define ϕ(s)=∑a∇θπθ(a∣s)Qπ(s,a)\phi(s)=\sum_a\nabla_\theta\pi_\theta(a\mid s)Q^\pi(s,a).

Differentiate Vπ(s)=∑aπθ(a∣s)Qπ(s,a)V^\pi(s)=\sum_a\pi_\theta(a\mid s)Q^\pi(s,a) and use the Bellman equation:

∇θVπ(s)=ϕ(s)+γ∑s′Pπ(s′∣s)∇θVπ(s′).\nabla_\theta V^\pi(s)=\phi(s)+\gamma\sum_{s'}P^\pi(s'\mid s)\nabla_\theta V^\pi(s').

The transition law has no direct parameter derivative, but the future policy still does. Repeated substitution produces discounted state visitations. This is different from differentiating an objective with an arbitrary stationary start distribution that itself depends on θ\theta.

Lecture 10 · Policy-Based Reinforcement Learning53 / 61
APPENDIXBackup slidesLecture 10

Backup 2 — the policy gradient theorem, the DP route (ii): unrolled

Let dγπ(s)=(1−γ)∑t≥0γtPπ(St=s∣S0∼μ)d_\gamma^\pi(s)=(1-\gamma)\sum_{t\ge0}\gamma^tP_\pi(S_t=s\mid S_0\sim\mu). This is a normalized discounted visitation distribution.

∇θJ(θ)=11−γEs∼dγπ, a∼πθ[∇θlog⁡πθ(a∣s)Qπ(s,a)].\nabla_\theta J(\theta)=\frac{1}{1-\gamma}\E_{s\sim d_\gamma^\pi,\,a\sim\pi_\theta}\big[\nabla_\theta\log\pi_\theta(a\mid s)Q^\pi(s,a)\big].

The factor 1/(1−γ)1/(1-\gamma) can be absorbed into a learning rate; the state weighting cannot simply be discarded. Finite-horizon episodic versions use a sum over time instead.

The trajectory route and the Bellman route agree when they describe the same objective and the same visitation weights.
Lecture 10 · Policy-Based Reinforcement Learning54 / 61
APPENDIXBackup slidesLecture 10

Backup 3 — the baseline: unbiased, and the best one

At a fixed state, put z=∇θlog⁡πθ(a∣s)z=\nabla_\theta\log\pi_\theta(a\mid s). Since E[z∣s]=0\E[z\mid s]=0, subtracting a fixed b(s)b(s) leaves the mean unchanged.

For the variance of one score-weighted contribution, minimize E[∥z∥2(G−b)2∣s]\E[\lVert z\rVert^2(G-b)^2\mid s]. Differentiation gives

b∗(s)=E[∥z∥2G∣s]E[∥z∥2∣s].b^*(s)=\frac{\E[\lVert z\rVert^2G\mid s]}{\E[\lVert z\rVert^2\mid s]}.

This equals Vπ(s)=E[G∣s]V^\pi(s)=\E[G\mid s] when the score weight is constant or suitably uncorrelated with return. Correlations across time add further considerations for a whole-trajectory variance optimum.

A value critic is a useful baseline, not a universal exact variance minimizer. Keep its output fixed during the actor derivative; same-sample fitting can introduce statistical dependence.
Lecture 10 · Policy-Based Reinforcement Learning55 / 61
APPENDIXBackup slidesLecture 10

Backup 4 — GAE, and the λ\lambda dial

With δtV=rt+1+γV(st+1)−V(st)\delta^V_t = r_{t+1} + \gamma V(s_{t+1}) - V(s_t), the kk-step advantage estimators telescope:

A^t(k)=∑l=0k−1γlδt+lV=−V(st)+rt+1+γrt+2+⋯+γk−1rt+k+γkV(st+k)\hat A_t^{(k)} = \sum_{l=0}^{k-1}\gamma^l\delta^V_{t+l} = -V(s_t) + r_{t+1} + \gamma r_{t+2} + \cdots + \gamma^{k-1}r_{t+k} + \gamma^k V(s_{t+k})

k=1k=1 is the one-step TD advantage: low variance, biased by whatever error VV carries. k=∞k=\infty is the Monte-Carlo advantage: unbiased, and as noisy as REINFORCE. GAE takes the exponentially weighted average of all of them, (Schulman et al., 2016)

A^tGAE(γ,λ):=(1−λ)(A^t(1)+λA^t(2)+λ2A^t(3)+⋯)=∑l=0∞(γλ)l δt+lV\hat A_t^{\mathrm{GAE}(\gamma,\lambda)} := (1-\lambda)\big(\hat A_t^{(1)} + \lambda\hat A_t^{(2)} + \lambda^2\hat A_t^{(3)} + \cdots\big) = \sum_{l=0}^{\infty}(\gamma\lambda)^l\,\delta^V_{t+l}

which collapses to a single running sum of TD errors. λ=0\lambda=0 recovers one-step actor–critic, λ=1\lambda=1 recovers Monte-Carlo.

This is TD(λ\lambda) applied to the advantage rather than to the value, and the discount γ\gamma is doing double duty: as the problem's discount, and as a variance-reduction parameter that downweights delayed effects at the cost of bias. Lecture 8's Backup 1 drew the same dial for MC-versus-TD; it is the same dial.

Lecture 10 · Policy-Based Reinforcement Learning56 / 61
APPENDIXBackup slidesLecture 10

Backup 5 — TRPO's natural-gradient step, in closed form

Maximise L(θ)=E[r(θ)A^]L(\theta) = \E[r(\theta)\hat A] subject to DˉKL(θold,θ)≤δ\bar D_{\mathrm{KL}}(\theta_{\mathrm{old}},\theta)\le\delta.

Step 1 — local models. To first and second order about θold\theta_{\mathrm{old}},

L(θ)≈g⊤(θ−θold),DˉKL≈12(θ−θold)⊤H (θ−θold)L(\theta)\approx g^\top(\theta-\theta_{\mathrm{old}}), \qquad \bar D_{\mathrm{KL}} \approx \tfrac12 (\theta-\theta_{\mathrm{old}})^\top H\,(\theta-\theta_{\mathrm{old}})

with g=∇θLg=\nabla_\theta L and HH the Fisher information matrix. The KL has zero gradient at θold\theta_{\mathrm{old}}, which is why its leading term is quadratic.

Step 2 — a linear objective on an ellipsoid. The maximiser lies along the natural-gradient direction H−1gH^{-1}g, scaled to the KL radius:

θnew=θold+2δ g⊤H−1g   H−1g\theta_{\mathrm{new}} = \theta_{\mathrm{old}} + \sqrt{\frac{2\delta}{\,g^\top H^{-1}g\,}}\;H^{-1}g

Step 3 — practice. H−1gH^{-1}g is obtained by conjugate gradient without ever forming HH, and the step is backtracked until the sample-estimated KL and surrogate improvement pass the line-search checks — which is Lecture 1's accept-or-shrink test, verbatim.

The derivation assumes an invertible positive-definite local Fisher matrix and a nonzero gradient. Implementations use damping and estimated quantities. PPO removes the second-order solve, but does not inherit a hard trust-region or monotonic-improvement guarantee.

Lecture 10 · Policy-Based Reinforcement Learning57 / 61
APPENDIXBackup slidesLecture 10

Backup 6 — the policy-based zoo, placed

These methods share policy optimization, but differ in objectives, estimators, data distributions and update rules. SAC explicitly includes entropy; PPO uses a clipped surrogate. A single vanilla policy-gradient formula does not specify every algorithm below.

Method Key idea Reference
REINFORCE Monte-Carlo policy gradient, no critic Williams, 1992
A3C / A2C parallel actor–critic; recent diverse rollouts Mnih et al., 2016
GAE λ\lambda-weighted advantage Schulman et al., 2016
DPG / DDPG deterministic actor climbs ∇aQ\nabla_a Q; off-policy Silver 2014; Lillicrap 2015
TD3 twin critics, delayed actor — the overestimation fix Fujimoto et al., 2018
TRPO approximate KL trust-region update Schulman et al., 2015
PPO clipped surrogate; the workhorse Schulman et al., 2017
SAC maximum-entropy off-policy actor–critic Haarnoja et al., 2018
Lecture 10 · Policy-Based Reinforcement Learning58 / 61
APPENDIXBackup slidesLecture 10

Source extension — MADDPG changes the number of decision makersoriginal policy-RL PDF pp. 71–74 · preview for IE579

With several agents, a critic can use the joint state and actions during training, while each actor uses its own observation when deployed.

Centralised trainingcritic for agent i sees joint information and actions
Actor improvementdifferentiate the critic through agent i's action
Decentralised executioneach actor acts from its permitted observation

This is centralised training with decentralised execution. Other agents' changing policies make the learning problem different from single-agent DDPG; actor gradients do not by themselves guarantee convergence to a Nash equilibrium.

This extension belongs to the multi-agent face of the course map. It is a preview, not a prerequisite for Lecture 11.
Lecture 10 · Policy-Based Reinforcement Learning59 / 61
APPENDIXBackup slidesLecture 10

The translation table — optimal control, learned

Every object of Lecture 9 has a data-driven counterpart. Keep this in sight all lecture.

Lecture 9 (optimal control) Lecture 10 (policy-based RL) What replaces the model
value field V(t,x)V(t,x), the HJB equation critic VwV_w, QwQ_w a learned value
feedback law u=γ(t,x)u=\gamma(t,x), u=−Kxu=-Kx actor πθ(a∣s)\pi_\theta(a\mid s) / μθ(s)\mu_\theta(s) a learned controller
known dynamics x˙=f(x,u)\dot x = f(x,u) sampled transitions (s,a,r,s′)(s,a,r,s') the environment itself
Pontryagin's costate, trajectory optimisation REINFORCE, trajectory sampling the score-function trick
solve Riccati / HJB gradient ascent on J(θ)J(\theta) stochastic optimisation
controllability of (A,B)(A,B) sufficient exploration a reachability assumption, either way

Read column 3. Nothing here is a new principle — it is Lecture 9's programme with the one piece we no longer own quietly swapped out. Policy gradient is optimal control with ff deleted and replaced by data. DDPG's actor μθ(s)\mu_\theta(s) is the learned cousin of LQR's gain KK; REINFORCE also uses trajectories, but its score-function gradient is a different mathematical argument from Pontryagin’s costate equations.

Lecture 10 · Policy-Based Reinforcement Learning60 / 61
APPENDIXBackup slidesLecture 10

One honest detour — why not identify the system?

The most literal idea, and the exact rhyme of the detour Lecture 8 took: estimate the dynamics from data, then run Lecture 9 unchanged.

(A^,B^)=arg min⁡A,B ∑t∥xt+1−Axt−But∥2⟹solve the Riccati equation for K^(\hat A,\hat B) = \argmin_{A,B}\ \sum_t \big\lVert x_{t+1} - Ax_t - Bu_t \big\rVert^2 \quad\Longrightarrow\quad \text{solve the Riccati equation for } \hat K

This is system identification, it is the oldest idea in adaptive control, and it is perfectly valid.

But notice the same waste Lecture 8 noticed. To act we only ever need the controller — m×nm\times n numbers, or one network — yet here we first estimate a whole dynamics model, and then we act as though it were true. Why estimate ff at all,

when we could estimate the controller directly?

That question — skip the model, learn the thing that acts — is the entire policy-based programme, and it is Lecture 8's question with Q∗Q^* replaced by πθ\pi_\theta. (The model comes back, deliberately and learned, in Lecture 11.)

Lecture 10 · Policy-Based Reinforcement Learning61 / 61

Keys

→ / space
next reveal, then next slide
←
back
↑ ↓
skip a whole slide
R
reset this slide's widgets and quizzes
M
slide index
P
print → save as PDF (1280×720)
F
fullscreen