5.2.9 · D1Deep & Advanced RL

Foundations — Proximal Policy Optimization (PPO)

2,862 words13 min readBack to topic

Before you can read the Proximal Policy Optimization (PPO) page, you meet a wall of symbols: , , , , , , , , . This page builds each one from nothing, in an order where every symbol is earned before it is used.


The stage: an agent living in a loop

Figure s01 (below) draws exactly this loop: the four rounded boxes are the four things that happen every tick — read State (top-left) → Policy picks Action (top-right, the agent decides arrow) → Reward (bottom-right) → World gives a new state (bottom-left, the world reacts arrow) → back up to State. Trace the arrows once and you have seen the entire game an RL agent plays.

Figure — Proximal Policy Optimization (PPO)

We give names to the pieces of this loop. Each name is a symbol you will see everywhere in PPO.


A whole run: the trajectory and its return


The decision-maker: the policy

Figure s02 (below) shows one such policy as a bar chart: four bars (up/down/left/right), heights are the probabilities, and they sum to . Notice "up" is tallest (most likely) while "left" is a short-but-nonzero bar — that surviving small bar is the exploration the entropy bonus later protects.

Figure — Proximal Policy Optimization (PPO)

The subscript : the knobs of the brain


Averaging over uncertainty:


Which actions were good? The advantage

Figure s03 (below) makes this concrete: three actions all give returns near (mint bars), and the red dashed line is the baseline . The label above each bar is — only survive. That subtraction is what separates good from bad when raw numbers all look alike.

Figure — Proximal Policy Optimization (PPO)

The discount and the trade-off knob


The learning move: , , and the ratio

Figure s04 (below) graphs this: the dotted diagonal is the untouched ratio , the lavender curve is . Inside the mint band the two coincide (clip does nothing); outside, the lavender line goes flat — a ratio of is pinned to , a ratio of is lifted to .

Figure — Proximal Policy Optimization (PPO)

Where all the symbols plug in: PPO's actual loss

Now that every symbol is defined, here is the objective PPO maximizes — the clipped surrogate:


How the foundations feed PPO

State s and Action a

Policy pi outputs action probabilities

Parameters theta are the knobs of pi

Trajectory tau and return R of tau

Objective J is average return

Expectation E averages over randomness

Value V of a state

Advantage A hat = better than average

Discount gamma and TD error

GAE lambda blends estimates of A hat

log and gradient nabla

Policy Gradient direction

Frozen pi old vs new pi gives ratio r

Clip with epsilon keeps r in safe band

PPO clipped objective


Equipment checklist

Test yourself — cover the right side.

What does stand for?
The state (snapshot of where the agent is / what it sees) at time-step .
What is a trajectory ?
One complete run through the loop — the ordered list ; a random object since the policy is random.
Write and say what it measures.
— the total discounted reward of one whole run.
What does equal?
— the average return over all paths the policy might take.
What does output, and what must the outputs sum to?
The probability of each action given state ; they sum to .
What is the difference between and ?
is the list of network knobs; is the policy those knobs produce.
Why keep a frozen ?
It's the reference the new policy must not drift too far from; it's also the policy that collected the data.
What does mean and equal for a fair die reward?
The long-run average of ; for a die it is .
Why does the policy gradient use ?
The log-derivative identity turns into an average we can estimate from sampled runs.
Why do we subtract to form the advantage?
To remove the state's baseline so only the difference between actions remains — cutting variance without bias.
Give the TD error formula.
.
Write the full GAE advantage.
.
What does trade off in GAE?
Bias vs variance ( low-variance biased one-step; unbiased noisy full return).
What does the gradient point toward?
The direction in knob-space of steepest increase of the quantity.
Write the probability ratio and say what means.
; means the new policy makes the action 20% less likely.
Write the PPO clipped-surrogate objective.
.
What does do to and to ?
Squashes ; leaves unchanged.