TRPO

In vanilla policy gradient methods, like REINFORCE, each update step moves the policy parameters in proportion to the advantage of sampled actions. Helpful actions get pushed up. Harmful actions get pushed down.

But policy networks are highly nonlinear. A small step in parameter space can cause a huge change in action probabilities. That can collapse exploration or erase prior good behavior.

For example, if a few random trajectories get high rewards, the model can overfit to them and forget everything else it had learned.

ℹ

Trust Region Policy Optimization

TRPO frames learning as constrained optimization: improve expected return, but do not let the new policy deviate too far from the old policy.

The deviation is measured by Kullback-Leibler divergence, or KL divergence, which quantifies how different two probability distributions are.

Trust-region lab

A modest parameter push can become a big policy shift

Imagine a few lucky trajectories made the action right look excellent. Increase the update pressure and watch the new policy drift away from the old one.

32%
left46%
old
55%
new
46%
stay25%
old
30%
new
25%
right29%
old
15%
new
29%

ratio for right

1.95

KL distance

0.056

trust limit

0.04

Outside the trust region

The action probabilities have shifted too far. TRPO would reject or shrink this update to avoid collapsing exploration or erasing useful behavior.

The trust region checks policy-space movement: Et[DKL] <= δ, not just parameter-space movement.

The ratio rt(θ)r_t(\theta) compares the probability of the sampled action under the new policy to its probability under the old policy.

If rt(θ)>1r_t(\theta)>1, the new policy assigns higher probability to that action. If rt(θ)<1r_t(\theta)<1, it assigns lower probability.

Equation walkthrough

TRPO improves the policy inside a constraint

Click each part of the constrained objective to see how TRPO turns policy improvement into a trust-region problem.

[]
subject to[]<=
where

Probability ratio

new policy divided by old policy

If the ratio is greater than 1, the new policy assigns higher probability to that sampled action. If it is below 1, the new policy assigns lower probability.

Terms

TRPO asks for the best advantage-weighted update whose average KL stays below δ.

TRPO's constrained objective is

max⁡θEt[rt(θ)At]\max_\theta \mathbb E_t[r_t(\theta)A_t]

subject to

Et[DKL(πθold∥πθ)]≤δ\mathbb E_t[D_{KL}(\pi_{\theta_{old}}\|\pi_\theta)]\le \delta

where

rt(θ)=πθ(at∣st)πθold(at∣st)r_t(\theta)=\frac{\pi_\theta(a_t\mid s_t)}{\pi_{\theta_{old}}(a_t\mid s_t)}

The objective Et[rt(θ)At]\mathbb E_t[r_t(\theta)A_t] encourages the policy to increase the probability of actions that led to above-average returns and decrease the probability of actions that performed worse than expected.

The KL term DKL(πθold∥πθ)D_{KL}(\pi_{\theta_{old}}\|\pi_\theta) measures how different the new policy's action probabilities are from the old policy's probabilities. The constraint Et[DKL]≤δ\mathbb E_t[D_{KL}]\le\delta keeps the update within a trust region, preventing large destructive policy changes.

That is the central promise of TRPO: steady, stable improvement without forgetting previously learned behaviors.

⚠

The Cost

TRPO is theoretically elegant and robust, but very computationally expensive.

That cost is one reason PPO became so popular: it keeps much of the trust-region intuition while being simpler to optimize.

Checkpoint

What problem is TRPO mainly trying to prevent with its KL-divergence constraint?