Emphatic-TD Methods in RL
Off-policy updates visit the wrong states too often, so some corrections need extra weight. Emphatic TD adds that weight with a followon trace.
Why Does This Exist?
Off-policy learning with function approximation can diverge. You follow one behavior policy to collect data but evaluate a different target policy, while bootstrapping from your own guesses. That trio is the deadly triad, and on tasks like Baird's counterexample plain TD weights grow without bound.
The importance ratio fixes which action was picked, where is the target policy and is the behavior policy. It does not fix which states you visit. States the behavior policy loves still dominate the updates even when the target policy rarely visits them.
Emphatic TD fixes the state weighting with one extra scalar per step. It keeps a single weight vector and one step size, unlike gradient TD methods which need a second weight vector and two timescales.
The one idea you need first
Interest says how much you care about state . Use everywhere for plain evaluation, or 1 on states you care about and 0 elsewhere for selective prediction. Everything else builds on that choice.
Think of It Like This
A teacher grading borrowed homework
You grade homework from a night class (behavior policy) but the grades count for the day class (target policy). Some day-class topics appear constantly in the night pile, others almost never.
If you grade every sheet equally, the overrepresented topic steers the whole curve. So you attach a slip to each sheet saying how much day-class work depended on it. Sheets that many day-class answers build on get a heavy slip, loners get a light one. The average then tracks the day class, not the night pile.
Where it stops: a teacher can reweight after seeing the pile. Emphatic TD builds the weight forward step by step, before seeing the future.
How It Actually Works
The followon trace carries past interest forward. Start with . Then:
Here discounts the future and is the importance ratio of the step that arrived here. Emphasis turns followon into an update weight. For one-step ETD with , emphasis equals followon:
The weight update with features , error , and step size is:
In expectation this reweights states toward the target visitation instead of the behavior visitation, which restores a positive definite system matrix and a stable fixed point.
Worked example
Use , , interest , features and , weights , so values are and . Rewards are 0.
Step 0 goes to . Followon and emphasis start at and . Target picks the action for sure while behavior picks it half the time, so . The error is . The update adds on the first weight, giving .
Step 1 stays in . Followon inherits the last step:
Both policies agree here so . The value is still , so . The update adds , giving .
The downstream correction got boosted because had bootstrapped from through an off-policy step. That boost is the whole method.
Code
Followon is one line. Emphasis equals followon for one-step ETD, and the effective step grows with it.
def followon(f_prev: float, rho_prev: float, gamma: float, interest: float) -> float: return gamma * rho_prev * f_prev + interest # inherited plus fresh interest
f0: float = 1.0f1: float = followon(f0, 2.0, 0.9, 1.0)print(f"{f0:.1f} {f1:.1f} {0.05 * f1 * 1.0 * -0.2 * 2.0:.3f}")# -> 1.0 2.8 -0.056The triple is , , and the second-coordinate change that moves 1.000 to 0.944. It matches the hand steps.
Watch Out For
Watching emphasis spike on long off-policy chains
Followon multiplies past ratios, so two or three large values in a row push into the tens or hundreds. The effective step then jumps far past a safe range and weights lurch.
Damp it with above 0, start smaller than your on-policy value, and clip in code that runs on logged data. If you see occasional huge updates amid calm ones, this is the cause.
Leaving interest at one everywhere without thinking
Uniform interest is fine for full evaluation, but it lets high-traffic behavior states dominate followon. When you only care about start states or a subtask, uniform interest wastes stability budget where it does not matter.
Set to 1 on states you actually predict and 0 elsewhere. Followon then channels emphasis to their ancestors instead of spreading it thin.
The Quick Version
- Emphatic TD reweights each update by emphasis built from followon .
- Followon adds fresh interest to discounted, ratio-weighted past interest.
- One-step ETD sets and keeps one weight vector with one step size.
- The reweighting restores a contracting update under off-policy sampling.
- The price is variance: long chains of large ratios spike , so damp or clip it.