Advantage Actor-Critic (A2C)
A2C judges each action against what the critic expected, not against zero. Actions that beat the baseline get reinforced and actions that miss it get dialed back.
Why Does This Exist?
Plain policy gradient methods such as REINFORCE learn from full-episode returns. The gradient points the right way on average, but the noise is brutal. The same state-action pair can score wildly different returns depending on lucky or unlucky steps hundreds of moves later. When every return is positive, the update pushes up the probability of everything it saw and separates good moves from mediocre ones only by degree.
The fix keeps the gradient unbiased while shrinking its noise. Subtract any baseline that depends on the state but not the action, and the expected update does not move, because the score function averages to zero over actions. The best such baseline is the state value itself. That difference has a name: the advantage . Positive means better than expected. Negative means worse.
This page covers the synchronous version of that idea. You get the advantage estimator the critic actually computes, the two losses trained together, the lockstep batching that replaced A3C threads, and one transition worked by hand. For the architecture without the advantage math, read actor-critic architecture first. For the async predecessor, the sequel is asynchronous advantage actor-critic.
Think of It Like This
A darts coach who knows your average
You throw darts while a coach tracks your average score per visit.
Without the coach you only hear your raw total at the end of the night. A 60 sounds good until you learn everyone hits 60 when the board is kind. You cannot tell which throws were skill and which were luck.
With the coach every throw gets judged against your average. Hitting 85 when you average 60 earns praise and you repeat that stance. Hitting 40 earns a correction even though 40 still scores points. The coach never throws. They supply the baseline and the verdict , and you adjust.
Where it stops: a coach sees your form and the room. The critic sees only numbers and learns its baseline from the same noisy rewards it judges, so early in training its averages are wrong and its verdicts mislead.
How It Actually Works
Symbols for this page: is the state, the action, the actor policy with weights , the critic value with weights , the reward, the discount, and the one-step TD error that stands in for the advantage.
The policy gradient with a state baseline reads:
Nobody knows exactly, so A2C estimates the advantage from the critic you already train:
Conditioned on the pair , the expectation of equals , which is the advantage. One critic, no second network.
The two losses trained together
The actor climbs the advantage-weighted log probability and keeps exploring through an entropy bonus with strength :
Entropy is highest for a uniform policy and zero for a deterministic one, so the bonus resists early collapse onto one action. The critic regresses toward the one-step Bellman target:
Shared backbones add the two with a critic weight near . Batches come from environments stepped in lockstep: one batched forward pass on the GPU, simultaneous actions, one tensor for the backward pass. No Hogwild threads, no stale writes, far better device use than A3C.
Worked example with advantage plus 2.44
State features are and . Critic weights are , reward , discount . Actor logits are and the agent picks action . Entropy weight .
Critic values come from dot products:
The TD advantage follows:
Positive and large: this transition beat expectations by a mile. Softmax over gives exponentials summing to , so probabilities are . The log probability of the chosen action is . Entropy is:
Losses:
Because is positive, the gradient step raises the probability of . That is the mechanism in one line: the critic sets the bar, the gap decides the push.
Code
A short check of the worked numbers above, with type hints throughout:
import mathfrom typing import List
def dot(a: List[float], b: List[float]) -> float: return sum(x * y for x, y in zip(a, b))
def softmax(logits: List[float]) -> List[float]: exps = [math.exp(v) for v in logits] total = sum(exps) return [e / total for e in exps]
w_c = [0.5, 1.0]s = [1.0, 0.5]s_next = [0.8, 1.2]reward = 2.0gamma = 0.9beta = 0.01
v = dot(w_c, s)v_next = dot(w_c, s_next)delta = reward + gamma * v_next - vprint([round(v, 4), round(v_next, 4), round(delta, 4)])# -> [1.0, 1.6, 2.44]
probs = softmax([0.6, 0.2])print([round(p, 4) for p in probs])# -> [0.5987, 0.4013]
logp = math.log(probs[0])entropy = -(probs[0] * math.log(probs[0]) + probs[1] * math.log(probs[1]))print([round(logp, 4), round(entropy, 4)])# -> [-0.513, 0.6735]
actor = -logp * delta - beta * entropycritic = 0.5 * delta * deltaprint([round(actor, 4), round(critic, 4)])# -> [1.245, 2.9768]# -> expected output:[1.0, 1.6, 2.44][0.5987, 0.4013][-0.513, 0.6735][1.245, 2.9768]Watch Out For
Letting the actor sprint ahead of the critic
The advantage is only as honest as the baseline. If the actor learns faster than the critic, reflects critic error rather than action quality, and the policy chases states where the critic merely underpriced the value. The symptom is early collapse: entropy falls, one action dominates, and returns plateau below what the same budget should reach.
Give the critic the faster schedule, often two to five times the actor step size, and keep nonzero until values settle. When sharing a backbone, weight the critic loss so its features stay accurate. Distrust big advantages while the critic loss is still large.
The Quick Version
- A2C scales each policy update by the advantage , so better-than-expected actions rise and worse ones fall.
- The one-step TD error estimates the advantage with no separate network.
- Subtracting the baseline keeps the gradient unbiased because the score function averages to zero over actions.
- One worked step gives values and , advantage , actor loss and critic loss .
- environments step in lockstep for one batched GPU update, which replaced A3C threads and their stale writes.
- Entropy bonus keeps the policy exploring until the critic becomes trustworthy.