CS285 DRL Notes-Lecture 6 Actor-Critic
This is the note for Berkeley CS285 Lecture 6. The lecture turns REINFORCE into actor-critic by learning a value function that gives each action a less noisy credit signal.
The actor decides what to do; the critic estimates how much that decision improves the future. Actor-critic is therefore policy gradient with learned credit assignment.
Why add a critic?
REINFORCE weights an action by one sampled reward-to-go. That sample is correct on average, but it contains randomness from every later transition and action.
Lecture 6 keeps the value-function notation from Lecture 4 and defines
$Q^\pi$ asks how good one action is, $V^\pi$ asks how good the state is under the policy, and $A^\pi$ asks whether the action is better or worse than the policy’s usual action at that state.
The policy-gradient estimator becomes
The actor is still updated through $\log\pi_\theta$. This formula uses the exact $A^\pi$; the practical question is how to construct a useful estimate $\hat A^\pi(s_t,a_t)$ from samples.

The critic does not predict the action and does not replace the reward. It averages over possible futures so that the actor does not have to learn from raw trajectory noise.
How can the critic learn a value with no labels?
For a fixed policy $\pi$, estimating its value is called policy evaluation. The policy-evaluation slides now introduce a discount $\gamma$; setting $\gamma=1$ recovers the finite-horizon definitions above. The Bellman identity supplies the structure:
This is an identity for the true value function, not yet a training rule. We can turn it into two kinds of regression targets.
Monte Carlo target
Wait until the trajectory ends and use the observed return
Then fit the lecture’s value estimator $\hat V_\phi^\pi$ by minimizing
$G_t$ uses the real future, so it does not inherit approximation error from the critic. Its weakness is variance: the same state can lead to many different sampled returns.
One-step TD target
Use one observed transition and let the critic estimate everything after it:
with $\hat V_\phi^\pi(s_{H+1})=0$ at the terminal state. The target is treated as a constant when updating the critic:
This is bootstrapping: one estimate is trained toward another estimate. It learns from incomplete trajectories and usually has lower variance, but an inaccurate $\hat V_\phi^\pi(s_{t+1})$ makes the target biased.
| Target | Uses real rewards for | Variance | Critic-induced bias |
|---|---|---|---|
| Monte Carlo $G_t$ | the whole future | high | none |
| one-step TD $y_t$ | one step | usually lower | strongest dependence on $\hat V_\phi^\pi$ |
| $n$-step return | the next $n$ steps | usually between the two | usually decreases as $n$ grows |
The discount $\gamma$ and the bootstrap horizon solve different problems. $\gamma$ defines how the objective values delayed rewards and keeps continuing returns finite; the bootstrap horizon controls how much the estimator trusts the critic. Discounting can also be interpreted as terminating after each transition with probability $1-\gamma$.
For a genuinely finite-horizon task, value generally depends on time. Following Lectures 4 and 6, this note keeps $t$ in the arguments $s_t,a_t$ while writing $V^\pi$ and $Q^\pi$; the fully explicit alternatives are $V_t^\pi(s)$ and $Q_t^\pi(s,a)$.
One critic estimate drives both networks
Subtracting the current value estimate from the TD target gives the one-step critic estimate used in the slides:
If $\hat V_\phi^\pi=V^\pi$, the conditional expectation of this quantity is the true $A^\pi(s_t,a_t)$.
This explains the basic actor-critic update:
- collect on-policy trajectories ${\tau^{(i)}}_{i=1}^{N}$;
- train the critic toward ${y_t^{(i)}}$;
- use $\hat A_C^\pi(s_t,a_t)$ as the action’s estimated advantage;
- increase $\log\pi_\theta(a_t\mid s_t)$ when $\hat A_C^\pi>0$ and decrease it when $\hat A_C^\pi<0$.
The actor update is
There is an important distinction:
- $G_t-\hat V_\phi^\pi(s_t)$ is still an unbiased policy-gradient weight because any state-only baseline has zero expected score gradient, even if the baseline is imperfect.
- $\hat A_C^\pi$ replaces the real future with $\hat V_\phi^\pi(s_{t+1})$. It has lower variance, but an imperfect critic can bias the actor update.
Actor-critic is useful because a small amount of bias can be much easier to learn from than a huge amount of variance.
GAE chooses how far to trust real experience
One-step TD trusts the critic after one reward. Monte Carlo trusts it only as a baseline after the complete return. An $n$-step advantage connects the two:
Small $n$ usually means lower variance and more critic bias. Large $n$ usually means higher variance and less critic bias. The slide’s displayed reward sum ends at $t+n$; the upper limit above is $t+n-1$ so that an $n$-step estimator contains exactly $n$ rewards before bootstrapping from $s_{t+n}$.
Generalized Advantage Estimation (GAE) avoids choosing one horizon. It exponentially combines all of them, which simplifies to a discounted sum of TD errors:
This is the slide’s infinite-horizon form. For a finite rollout, the implementation truncates the sum at $H$ and uses the available bootstrap value at the boundary (zero at a true terminal state).

The parameter $\lambda$ controls estimator trust:
- $\lambda=0$: one-step TD; strongest bootstrapping, usually lowest variance;
- $\lambda\to1$: approaches Monte Carlo advantage on a complete trajectory; weaker critic bias, usually higher variance;
- between them: a smooth bias-variance tradeoff.
$\gamma$ changes what future reward means; $\lambda$ changes how that return is estimated. They appear together as $\gamma\lambda$, but they are not interchangeable.
PyTorch implementation
This implementation works backward through $N$ on-policy trajectories of horizon $H$. The code names values, deltas, and advantages correspond to $\hat V_\phi^\pi$, $\delta_t$, and $\hat A_{\mathrm{GAE}}^\pi$. Set the final next_values entry to zero for a terminal state, matching $\hat V_\phi^\pi(s_{H+1})=0$.
1 | |
Use the advantages as fixed actor weights and the value targets as fixed critic labels. The example assumes actor(states) returns a distribution whose log_prob(actions) has shape [N, H]; for vector-valued continuous actions, sum the per-dimension log-probabilities first.
1 | |
Advantage normalization is an optimization heuristic: centering removes batch-wide offset and scaling makes the step size less sensitive to reward magnitude. GAE supplies the credit signal; algorithms such as PPO add another mechanism for controlling how far the policy may move.
Why replay breaks the on-policy derivation
Suppose the replay buffer $\mathcal R$ contains transitions generated by an older policy $\bar\pi$. Naively reusing stored actions creates two mismatches:
- A $V^\pi$ Bellman target averages over actions from the current policy, but the stored action came from $\bar\pi$.
- The policy-gradient sample also requires $a\sim\pi_\theta(a\mid s)$; inserting a stored $a\sim\bar\pi(a\mid s)$ is not the same estimator.
The key repair is to learn $Q(s,a)$, because it conditions on the stored action instead of averaging that action away.
For a replay batch ${(s_i,a_i,s_i’)}_{i=1}^{B}$, use the target from the lecture:
and fit
The old action $a_i$ is valid on the left because $Q$ is conditioned on it. The next action $a_i’$ must be freshly sampled from the latest policy because the target is evaluating that policy.

The actor also samples a fresh action at each replay state:
This preserves the slide’s formula. In a score-function implementation, $\hat Q_\phi^\pi$ is held fixed during this actor step, just as the sampled weights were in Lecture 5; the slide does not write an explicit stop-gradient.
The replay states come from $\mathcal R$ rather than the current policy’s state marginal $p_\theta(s)$. Thus, despite the slide’s $\nabla_\theta J(\theta)$ label, this is generally a replay-distribution update direction rather than an unbiased gradient of the original on-policy objective. The slide describes the replay distribution intuitively as broader, but a real buffer may also have poor coverage. Reusing its data can improve sample efficiency; it does not guarantee it.
Reparameterization differentiates through the action
For the continuous Gaussian policy used in the lecture,
Slide 32 uses this plus sign, while the algorithm on slide 33 shows a minus sign. The note keeps the sampling identity from slide 32. A symmetric Gaussian noise variable makes the two samples equal in distribution, but the plus sign keeps the computation consistent from sampling through differentiation.
The randomness now lives in $\epsilon$, whose distribution does not depend on $\theta$. Therefore
can be differentiated directly through the action:

During the actor update, $\phi$ is fixed, but gradients flow through $\hat Q_\phi^\pi$ with respect to its action input. This reparameterized gradient is convenient for continuous actions and often has lower variance than the score-function estimator. Soft actor-critic builds on this idea, together with stronger Q-learning machinery and entropy regularization.
Common confusions
- Does the critic give rewards? No. Rewards come from the environment; the critic predicts expected return from those rewards.
- Is a critic an environment model? No. It predicts a scalar value, not the next state or full dynamics.
- Is $\delta_t$ exactly the advantage? Only in conditional expectation when the value function is exact. With an approximate critic it is an estimator.
- Does any inaccurate baseline bias policy gradient? A state-only baseline subtracted from Monte Carlo return does not. Bias enters when an inaccurate value is used to replace unobserved future rewards through bootstrapping.
- Are $\gamma$ and $\lambda$ the same kind of discount? No. $\gamma$ belongs to the return objective; $\lambda$ belongs to the advantage estimator.
- Can stored actions be inserted directly into an ordinary policy gradient? Not without an off-policy correction. Replay-based actor-critic instead conditions the critic on stored actions and samples fresh actor actions.
My takeaway
Actor-critic is easiest to understand as a credit-estimation system. The actor update itself barely changes; most of the design work goes into deciding what number should multiply $\nabla\log\pi$.
Monte Carlo return is honest but noisy. Bootstrapping is quieter but trusts an imperfect critic. GAE exposes this as a continuous choice rather than a binary one. Off-policy actor-critic makes a second trade: it gives up the exact current-policy state distribution so that experience can be reused, and a learned $Q(s,a)$ makes that reuse possible.