The goal of reinforcement learning is to find an optimal behavior strategy for the agent to obtain optimal rewards. Policy gradient methods target at modeling and optimizing the policy directly (as opposed to value-based methods that model a value function and derive the policy from it). The policy is usually modeled with a parameterized function respect to , The value of the reward (objective) function depends on this policy and then various algorithms can be applied to optimize for the best reward.
The reward function is defined as:

where is the stationary distribution of the markov chain for (on-policy state distribution under ).
Using gradient ascent, we can move toward the direction suggested by the gradient to find the that maximizes the return.

Via the policy gradient theorem, we can drop from the gradient (i.e. don’t need to know / differentiate the environment).
We end up with the vanilla policy gradient:

See vanilla policy gradient for a more detailed explanation of the most basic policy gradient algorithm / how we derive the gradient of this objective. Below is a more general formulation of different policy gradients, based on the High-Dimensional Continuous Control Using Generalized Advantage Estimation paper.

Policy gradient methods

Let be sampled from initial distribution . A trajectory is generated by:

  • Sampling actions:
  • Sampling states:

until reaching a terminal state. At each timestep, a reward is received. The goal is to maximize the expected total reward (assumed to be finite).

Policy gradient methods maximize the expected total reward by estimating the gradient :

where can take various forms, to estimate the contribution of each action to the total reward:

… Total trajectory reward, which is the original REINFORCE weight. Unbiased but highest variance: every action is credited with the whole trajectory’s reward, including rewards collected before that it couldn’t have caused.
… Future reward after action (reward-to-go), drops the past rewards can’t influence. It’s variance is strictly lower, but the expectation stays the same. This is the standard REINFORCE form in practice.
Baselined reward-to-go; is supposed to remove variance of the state, and focus the reward on the reward difference caused by actions in a specific state. does not bias the gradient, because it depends only on the state and not the action, so it cancels in expectation over actions (proof below).

The above options pass a sampled return to : this is the last unbiased option.
The below instead passes a learned value function, trading bias (approximation error) for lower variance.

state-action value replaces the sampled return with its expectation. This is the actor critic move: a learned critic estimates , cutting variance a lot, but adding bias whenever the critic is imperfect.
advantage function — with as the baseline. The sweet spot: near-lowest variance because it measures better/worse than the state’s average action directly (see below). De-facto target of modern methods (A2C/A3C, TRPO, PPO); never known exactly, so it’s estimated, usually via GAE.
TD residual — a one-step, bootstrapped estimate of the advantage ( under the true ). Cheapest advantage: needs only , no separate -net. Most biased / most reliant on the value estimate; GAE dials between this (low variance, high bias) and the Monte-Carlo advantage (high variance, low bias) via .

where
state-value; expected total reward from state
state-action value; expected total reward from state and action

Choosing the advantage function for yields almost the lowest possible variance, though in practice, the advantage function is not known and must be estimated. This statement can be intuitively justified by the following interpretation of the policy gradient: that a step in the policy gradient direction should increase the probability of better-than-average actions and decrease the probability of worse-than-average actions. The advantage function, by it’s definition measures whether or not the action is better or worse than the policy’s default behavior. Hence, we should choose to be the advantage function, so that the gradient term points in the direction of increased if and only if .

Why a state-dependent baseline doesn't bias the gradient

Subtracting adds one extra term to the gradient: . Because depends only on the state, pull it out of the expectation over actions and it collapses to zero:

The middle step is the log-derivative trick in reverse (); the last step uses that probabilities sum to , whose gradient is . So the score has zero mean under , and subtracting any action-independent shifts the gradient by nothing in expectation — it only changes the estimator’s variance. A natural, near-optimal choice is , which turns the weight into the advantage (see above). The requirement is strict: a baseline that depended on would not cancel and would bias the gradient.

References

, but also inputs like are often ommitted in notation.

PPO

https://lilianweng.github.io/posts/2018-04-08-policy-gradient/