Week 11 · Actor-critic and PPO
Trace a critic estimate into a clipped policy update.
← Week 10 · Subject contents · Week 12 →
Trace a critic estimate into a clipped policy update.
Work through the problem
The critic estimates V(s). A one-step advantage estimate is A=r+γV(s′)−V(s). If r=1, γ=0.9, V(s′)=2, and V(s)=2.5, then A=0.3. The policy gradient increases the relative chance of actions with positive estimated advantage.
PPO uses the ratio rᵢ=π_new(aᵢ|sᵢ)/π_old(aᵢ|sᵢ) and maximizes min(rᵢAᵢ, clip(rᵢ,1−ε,1+ε)Aᵢ). For A=2 and ratio 1.4, ε=0.2 caps the contribution at 2.4. For A=−2 and ratio 0.6, it limits the gain from reducing the ratio by keeping the objective at −1.6.
Run the Python lab
import numpy as np
ratio = np.array([1.4,.6,1.1])
advantage = np.array([2.,-2.,1.])
plain = ratio*advantage
clipped = np.minimum(plain,np.clip(ratio,.8,1.2)*advantage)
print("Critic advantage:",round(1+.9*2-2.5,2))
print("Plain:",plain)
print("PPO:",clipped)
assert np.allclose(clipped,[2.4,-1.6,1.1])
Output from the lab
Critic advantage: 0.3
Plain: [ 2.8 -1.2 1.1]
PPO: [ 2.4 -1.6 1.1]
Practice
- Does clipping impose a hard maximum change on every policy probability?
Check your reasoning
- No. It changes the objective’s incentive on sampled actions. Other gradients and parameter sharing can still move probabilities.