Contents · Reinforcement Learning Theory
Part 0 · MDPs
Part 1 · Bellman & Value Iteration
Part 2 · Policy Gradients
- Policy Gradients and REINFORCE
Part 3 · Trust Regions
Part 4 · Actor-Critic
Part 2 · Policy Gradients
Policy Gradients and REINFORCE
The score-function gradient turned "differentiate an expectation" into "sample, then weight the score by the value." Policy gradients apply that same trick to control: the distribution is a policy over actions, and the value being maximized is the expected return. REINFORCE is the estimator that falls out, and a baseline is the one line that makes it usable.
The policy gradient theorem
Let a policy induce a trajectory distribution with expected return . The policy gradient theorem says the gradient is an expectation over the states the policy visits and the actions it takes,1
The environment dynamics never appear in the gradient. Only the score , the part we control, is weighted by , the value of taking that action. This is the score-function identity over actions instead of over an abstract sample .
REINFORCE: the sampled-return estimator
is unknown, but along a sampled trajectory the return is an unbiased sample of it. Substituting for gives the Monte Carlo estimator and its update,2
Actions that preceded a high return get their log-probability pushed up. It is unbiased but noisy: the return carries the variance of the whole future.
Baselines cut variance for free
Subtract any function that does not depend on the action. The expected update is unchanged, because the expected score is zero:
So , and replacing with keeps the estimator unbiased while changing its variance. Choosing centers the weight near zero, shrinking . The mean return is the simplest such baseline and already removes most of the noise.3
Worked example: softmax over K arms
Drop the state. With logits the policy is , and the score of a chosen arm is the one-hot vector minus the probability vector,
Start uniform, so for . Sample arm and observe reward . The score is
With no baseline and , the REINFORCE step is :
The probability of arm 2 rose from to . Now subtract a baseline , the average reward seen so far. The weight becomes :
Same direction, smaller step, because arm 2 only beat the average by one. The crucial case is an arm that pays exactly the average, : its update is . Below-average arms are pushed down. Without a baseline every arm here has positive reward, so every sampled arm is pushed up, and the policy has to separate the good from the mediocre out of noise alone. Centering by turns "how large is the reward" into "how much better than usual," which is the signal that actually matters.
- steps
- 0
- π(a3) best
- 25.0%
- avg reward
- 0.000
Turn the baseline off and the probability bars still march toward the green arm, but the variance bar jumps and the reward curve gets choppier: the update is being knocked around by the reward's mean level rather than its differences. This is the whole story of modern policy-gradient methods in miniature. Replace the running-mean baseline with a learned value function and the weight becomes the advantage, the object at the center of actor-critic and PPO.
Footnotes
-
Sutton, McAllester, Singh, Mansour, Policy Gradient Methods for Reinforcement Learning with Function Approximation (2000). ↩
-
Williams, Simple statistical gradient-following algorithms for connectionist reinforcement learning (1992). ↩
-
Sutton & Barto, Reinforcement Learning: An Introduction (2018). ↩