5.2.7 · D1Deep & Advanced RL

Foundations — Actor-critic methods

3,183 words14 min readBack to topic

This page assumes you have seen none of the notation. We build each symbol from a picture, in an order where every new symbol only uses symbols already defined.


0. The playground: an agent in a world

Before any symbol, picture the world the parent note lives in.

Figure — Actor-critic methods

Figure s01 shows the whole game as a loop. The white box on the left is the agent (the robot's "brain"); the white box on the right is the environment (the world). The red arrow is the one thing the agent controls — the action it sends into the world. The black arrow returning is what the world sends back: a reward number and a next state. Follow the red arrow, then the black arrow, and you have lived one full step of the game.


1. and — state and action (and where they live)

  • (read "ess") is a symbol for the current state — the snapshot in the picture above.
  • (read "ay") is a symbol for the action the agent takes in that state.
  • We write and where the subscript (read "at time ") means "at step number ." Step , step , step , … So is simply the next state.

2. — reward, and — the discount

  • is the reward the world pays after taking action in state . (It carries subscript because it arrives with the next state.)
  • (Greek letter "gamma," read "gam-uh") is the discount factor, a number .
Figure — Actor-critic methods

Figure s02 plots the shrink-factor against how many steps into the future a reward sits. The red bar at is the reward right now, weighted a full . Each black bar to the right is shorter — the same reward, worth less the later it arrives. This falling staircase is exactly why the sum below converges (see the definition).


3. — the policy (this is the ACTOR)

  • (Greek "pi," read "pie") is the agent's policy: its rule for choosing actions.
  • reads "the probability of action given state ." The vertical bar means "given" — it separates what we're guessing () from what we already know ().
  • reads " is sampled from the policy in state ." The squiggle means "drawn at random according to the probabilities listed by whatever is on its right." So = "roll the policy's weighted dice for state and let be the action that comes up." The dot is a placeholder standing for "the action slot" — we're naming the whole distribution over actions, not one specific action yet.
  • (Greek "theta," read "thay-tuh") is the bag of tunable numbers (weights) inside the policy, (a list of real numbers). We write to say "the policy shaped by settings ." Change → the dials move.

4. — the expectation symbol (before we can score anything)

We must define averaging before we write value functions, because a "how-good" score is literally an average.

  • (a stylised "E") means expected value = the long-run average of the thing in brackets over all the randomness.
  • reads "average over everything random when actions come from policy ." Concretely the randomness has three sources: which state you're in, which action samples (, the squiggle just defined in §3), and which next state the environment transitions to.

5. and — value functions (this is the CRITIC)

Two "how-good" scores. Both are averages of the return (using the just defined), but they condition on different things.

Figure — Actor-critic methods

Figure s03 makes the difference visual. The single left circle is the state ; the label above it, , scores the whole spot. The three branches are the three possible actions; each landing circle carries its own . The red branch () is highlighted to show that is one number per action, while is one number for the state — literally the average of the 's weighted by how often the policy picks each branch.

  • and : the subscript (with ) is another bag of tunable numbers — the critic's weights. is our learned estimate of the true .

6. The advantage — the star of the show

Figure — Actor-critic methods

Figure s04 shows why we subtract. The three black bars are for three actions — all towering near . The red horizontal line is the pedestal . What the actor cares about is only the little bit sticking above or below the red line — the advantage , printed above each bar (). Its sign cleanly says "push this action's probability up" () or "down" (). This is the advantage function, and the pedestal-removal is the whole reason the critic reduces variance.


7. — the TD error (turning into , the shared signal)

First: why can be written from (the one-step recursion)

We rarely know exactly, and we do not want to learn a separate . The trick is a small derivation. Start from the definitions in §5 and split the return into "the first reward" plus "everything after":

Why this split? The return is defined as a sum where every term past the first already carries one factor of ; factoring that out leaves exactly — the return starting one step later. Now take the average of both sides. On the right, is by the very definition of just . This gives the one-step recursion (a Bellman equation):

In words: the value of an action = the immediate reward you collect, plus the discounted value of wherever you land. This is the bridge that lets a -only critic estimate .

Then: the sample estimate

Dropping the average and using the critic in place of the unknown true , a one-sample estimate of the advantage is:


8. Gradients, the objective, the credit signal , and the update rules

  • (the symbol is "nabla" or "grad") is the gradient with respect to : an arrow pointing in the direction that most increases whatever follows it, as you wiggle the knobs .
  • here means the natural logarithm (base ), the convention used everywhere in machine learning. is "the direction in knob-space that makes action more probable."
  • (Greek "alpha") = the learning rate / step size: how big a nudge each update makes. We use for the actor and for the critic (typically so the critic keeps ahead).

Prerequisite map

state s and action a

reward r and discount gamma

return G total future reward

policy pi theta the actor

expectation E averages over luck

value V and Q the critic

advantage A equals Q minus V

TD error delta one step advantage

grad log pi nudge direction

objective J expected return

credit signal Psi slot

Actor-Critic update

Read it bottom-up: states and rewards define returns; the expectation averages them into values and the objective ; values minus values give the advantage; the advantage collapses to the TD error; the TD error fills the credit slot and, times the gradient-of-log direction, is the actor-critic update.


Equipment checklist

Cover the right side and see if you can state each from memory.

What does mean?
The probability of action given state , under a policy tuned by knobs — the actor.
What does mean?
Action is sampled (drawn at random) from the policy's probabilities for state .
What does equal, formally?
— the average future discounted return from state under .
What does equal, formally?
— average return after forcing action in , then following .
Write the one-step recursion linking and .
— reward now plus discounted value of the landing state.
What is , and when does its sum stop?
; it stops at the terminal step in episodic tasks, and converges for continuing tasks when .
What does do?
Shrinks rewards that arrive later (), making far-future rewards count less and the return sum converge.
Define the advantage in words.
How much better action is than the average action in state : .
Write the TD error , and its terminal-state form.
; at the last step set so .
What is the credit signal , and what do REINFORCE vs actor-critic put in it?
The placeholder for "how much we liked the action"; REINFORCE uses , actor-critic uses .
What base is the in ?
The natural logarithm (base ), the ML convention.
Write the actor update rule.
.
Write the critic update rule.
.
What is the objective ?
— the expected return from the start under policy ; the actor climbs it.
Why does update BOTH networks?
It is the critic's prediction error and a one-sample estimate of the advantage for the actor.
What sets do and live in?
(state space), (action space, discrete or continuous).

Connections