๐Ÿš‘ Off-Policy Policy Gradient

Reinforcement Learning / Policy Gradient

The standard ๐Ÿš“ Policy Gradient method is on-policy, requiring samples collected by running the same policy we're optimizing for. Once we update our policy, we need to collect new samples.

The goal of the off-policy policy gradient is to be able to update our policy using samples not from our trajectory. Let be our desired target policy and be the policy that generated our samples.

We start with the original objective and apply ๐Ÿช† Importance Sampling to rewrite the expectation in terms of the sample distribution :

Next, we can apply the ๐Ÿฆ„ Log Derivative Trick:

While this gradient can work on its own, there are a few adjustments we make for practicality. First, similar to ๐Ÿš“ Policy Gradient, we can use causality,

However, these importance weights are problematic: products grow exponentially, which increases the variance of our estimates. To address this, we can:

  1. Ignore the second product, which gives us a โ™ป๏ธ Policy Iteration algorithm that can be shown to still improve the policy, even if it's no longer the actual gradient.
  2. For the first product, only use the importance weight at as an estimation. The reasoning is that if we look at the state-action marginal (occupancy measure) formulation of our objective, we get

by assuming . This approximation, applied to the trajectory-level objective, analogously gives us

Note that while this not technically the correct policy gradient, the error is bounded if is close to , and it allows us to avoid the exponential blowup.

Content by William Liang, written in Obsidian.
Thank you to all the educators who made these notes possible.