5.2.10 · D3Deep & Advanced RL

Worked examples — Trust Region Policy Optimization (TRPO)

3,289 words15 min readBack to topic

This page is a drill. We take the parent TRPO note and hit every case the TRPO step can throw at you: positive and negative advantage, easy diagonal Fisher matrices, nasty non-diagonal ones, degenerate inputs (zero gradient, singular Fisher, tiny trust region), the limit of shrinking , a real-world word problem, and an exam-style twist. Every number is verified at the bottom.

Nothing here assumes you can already crunch the formula. We re-derive the tools as we need them.


The three earned symbols

Before any example, we pin down the three symbols the TRPO step is made of, so nothing is used before it is defined.

Now the last earned symbol. The expression appears in every example, so let us name what it is.


The scenario matrix

Each row is a "cell" we must cover with at least one worked example.

Cell What varies Why it can trip you up Covered in
A Diagonal Fisher, positive advantage The "textbook" easy case Ex 1
B Advantage sign flips () Objective should push probability down Ex 2
C Non-diagonal (correlated) Fisher You must actually invert a Ex 3
D Degenerate: zero gradient Step must be zero; formula has risk Ex 4
D' Degenerate: singular (non-invertible) does not exist at all Ex 4b
E Very small (limiting behaviour) Step scales like , not Ex 5
F Line search rejects a step The math step is only a proposal Ex 6
G Real-world word problem Translate a scenario into , , Ex 7
H Exam twist: KL of two Gaussians KL is not symmetric; direction matters Ex 8

Ex 1 — Cell A: diagonal Fisher, positive advantage

Figure — Trust Region Policy Optimization (TRPO)

What the figure shows: the teal ellipse is the KL wall — every point on it costs exactly of KL. Because axis 2 has high Fisher (), the ellipse is squashed vertically (you can move far along axis 1 but only a tiny bit along axis 2 for the same KL). The plum arrow is the raw gradient direction, the orange arrow is our step , and it touches the ellipse right on axis 1 — visually confirming we spent the whole KL budget in the cheap direction.


Ex 2 — Cell B: negative advantage flips the direction


Ex 3 — Cell C: correlated (non-diagonal) Fisher

Figure — Trust Region Policy Optimization (TRPO)

What the figure shows: the teal ellipse is again the KL wall, now tilted because the off-diagonal in correlates the two parameters. The plum arrow is the raw gradient (pure 45°); the orange arrow is the natural-gradient step, which here still points at 45° (since is an eigenvector) but is shortened by the curvature. The picture makes the lesson concrete: Fisher reshapes both the wall and how far you may travel.


Ex 4 — Cell D: degenerate input, zero gradient


Ex 4b — Cell D': degenerate input, singular Fisher


Ex 5 — Cell E: the limiting law

Figure — Trust Region Policy Optimization (TRPO)

What the figure shows: the teal curve plots step length against the trust-region size . The three marked dots () sit at heights — each dot half the height of the previous even though dropped to a quarter. The curved (not straight) shape is the visual signature of the square-root law: tightening the trust region buys you safety cheaply in step length.


Ex 6 — Cell F: the line search rejects the proposal


Ex 7 — Cell G: real-world word problem


Ex 8 — Cell H: exam twist — KL of two Gaussians (direction matters)

Figure — Trust Region Policy Optimization (TRPO)

What the figure shows: two bell curves — the teal old policy and the orange new policy , same width, shifted right by . The plum arrow marks the mean shift. The visual point: a modest-looking horizontal slide of standard deviations costs only nats of KL, comfortably inside the wall — matching the quadratic mean-shift law.


Recall Which cells did each example cover?

Ex 1 covers cell ::: A (diagonal Fisher, positive advantage) Ex 2 covers cell ::: B (negative advantage flips the step, stays positive) Ex 3 covers cell ::: C (non-diagonal Fisher, real inverse) Ex 4 covers cell ::: D (zero gradient, limit gives ) Ex 4b covers cell ::: D' (singular Fisher, , fix with damping ) Ex 5 covers cell ::: E (, square-root scaling law) Ex 6 covers cell ::: F (line search rejects an optimistic step, quadratic backtracking) Ex 7 covers cell ::: G (word problem: Fisher damps high-curvature parameter) Ex 8 covers cell ::: H (Gaussian KL, quadratic in mean shift, asymmetry twist)

See also: Policy Gradient Methods, Conjugate Gradient Method, Proximal Policy Optimization (PPO).