Vanilla policy gradient (REINFORCE / A2C) updates θ←θ+α∇θJ.
The problem: the gradient is only accurate locally. A single large step can push the policy into a region where the collected data (samples from the old policy) no longer describes the environment well. Result: a bad update collapses performance, and because RL data depends on the policy, you may never recover.
TRPO answers: how large a step can I take and still guarantee improvement?
where Aπ(s,a)=Qπ(s,a)−Vπ(s,a) is the advantage under the old policy, and dπ′ is the discounted state-visitation distribution of the new policy π′.
Why this identity is beautiful: it says the improvement of a new policy equals how much extra advantage it collects, measured against the old policy's advantage function. But it's impractical: the states come from dπ′, which we can't sample until we already have π′.
The theoretical penalty coefficient C is huge, forcing tiny steps. TRPO instead turns the penalty into a hard constraint (a "trust region") with a tunable size δ:
We can't solve the constrained problem exactly for a deep net. TRPO approximates locally:
Linearize the objective around θold: L(θ)≈g⊤(θ−θold), where g=∇θL is the policy gradient.
Quadratically approximate the KL constraint: DˉKL≈21(θ−θold)⊤F(θ−θold), where F is the Fisher Information Matrix (the Hessian of KL, which is 0 to first order — that's why we need the quadratic term).
The problem becomes:
smaxg⊤ss.t.21s⊤Fs≤δ,s=θ−θold.
Solve with a Lagrangiang⊤s−λ(21s⊤Fs−δ). Setting derivative to zero: g−λFs=0⇒s=λ1F−1g.
Plug into the constraint 21s⊤Fs=δ to solve for λ:
Why is this smart?
We never form F−1 (huge). We compute F−1g via conjugate gradient, needing only Fisher-vector products Fv (cheap via a second autodiff).
Because approximations may violate the true constraint, TRPO does a backtracking line search: shrink the step by βj until the true KL ≤δand the surrogate actually improved.
Imagine you're adjusting a recipe you already cooked. You tasted the food (collected data) and know which changes make it better. But if you change too many ingredients at once, your old taste-notes no longer apply — you might ruin it. TRPO says: change the recipe in the best direction, but only a little bit each time — small enough that your notes still make sense. The "how much is too much" is measured by how different the new recipe is from the old one, not by how many numbers you changed.
What performance-difference identity does TRPO build on?
J(π′)−J(π)=Es∼dπ′,a∼π′[Aπ(s,a)] — new-minus-old return equals extra advantage collected.
Why is that identity impractical to use directly?
The states are drawn from dπ′ (the new policy's visitation), which we can't sample before we have π′.
What approximation gives the surrogate objective?
Replace dπ′ with dπ (valid when π′≈π), then importance-sample actions.
Write the TRPO surrogate objective.
Es,a∼πold[πold(a∣s)πθ(a∣s)Aπold(s,a)].
What is the TRPO constraint?
Mean KL divergence DˉKL(θold,θ)≤δ — a hard trust region in policy-distribution space.
Why constrain KL instead of ∥Δθ∥?
Equal parameter steps cause unequal distribution changes; KL measures distance in distribution space, which is what actually matters for validity of the surrogate.
What matrix approximates the KL constraint quadratically?
The Fisher Information Matrix F (Hessian of KL at θold).
Give the closed-form TRPO step.
s=g⊤F−1g2δF−1g, i.e. natural gradient scaled to the trust boundary.
How is F−1g computed without inverting F?
Conjugate gradient using Fisher-vector products Fv.
Why the backtracking line search after the CG step?
The linear/quadratic approximations may violate the true KL constraint or fail to improve the surrogate; line search shrinks the step until both hold.
What does F−1g (the natural gradient) represent geometrically?
The steepest-ascent direction measured in KL geometry rather than Euclidean parameter geometry.
What guarantee does the theory provide?
Monotonic (non-decreasing) improvement of true J when optimizing the lower bound L−C⋅DKL.
Dekho, RL me problem ye hai ki agar aap policy ko ek hi step me bahut zyada change kar do, toh jo purana data collect kiya tha wo naye policy ke liye galat ho jaata hai — aur RL me galat policy toh galat data banati hai, phir cheezein aur bigadti jaati hain. Isliye TRPO kehta hai: improvement ki direction me jao, par utna hi jao jitna "trust" kar sakte ho.
"Kitna trust karein" — yahi TRPO ka mast idea hai. Hum step ko θ (parameters) me nahi, balki policy distribution me measure karte hain, using KL divergence. Constraint ye hai: naya aur purana policy ka mean KL ≤δ hona chahiye. Yani ek chhota sa "speed limit" distribution-space me. Objective hum optimize karte hain wo hai surrogate — jisme importance ratio πoldπnew ko advantage A se multiply karte hain. Agar action achha hai (A>0), objective uski probability badhata hai; bura hai toh ghatata hai.
Solve kaise karte? Objective ko linear approx karo (gradient g), constraint ko quadratic approx karo (Fisher matrix F). Lagrangian solve karne pe step milta hai: s=2δ/(g⊤F−1g)F−1g. Ye F−1g hi natural gradient hai — matlab steepest direction, par KL geometry me. Practically hum F invert nahi karte (bahut bada hota hai), balki conjugate gradient se F−1g nikaalte hain, aur end me ek line search karke confirm karte hain ki actual KL constraint aur improvement dono theek hain.
Bottom line: TRPO ka guarantee hai ki har step me true return kam nahi hoga (monotonic improvement) — stable, safe learning. Baad me PPO isi idea ko simple bana deta hai (hard KL constraint ki jagah ratio clipping), par samajh TRPO se aati hai.