Course · Reinforcement learningPhase 12 · Study guide

Is the policy improving under a fixed evaluation protocol?

Domain Specialization · Local CPULaptop CPU5 lessons (~6.8h)

Revision v0.18.1 ·

A policy changes the data it will see next, so learning from interaction requires careful bookkeeping. A transition gives an immediate reward; a return combines later rewards; a value estimates expected return; an advantage compares an outcome with that baseline. Follow one short trajectory before introducing their batched estimators. Keep episode endings and collection cutoffs distinct when deriving targets. Then connect the sign of an advantage to a policy update, freeze the behavior probabilities needed for PPO comparisons and inspect variation across independent evaluation units. The small environment makes those choices visible before a larger control task.

Preparation: Neural network training

Runtime: CPU; target accelerator execution requires separate evidence

Check your starting point

An episode stops because its time budget expires. Must its bootstrap value be zero?

Compare your reasoning

Not necessarily. Distinguish truncation from genuine terminal states and state whether the task is finite-horizon or continuing. A timeout alone does not imply that future value is zero.

If this is unfamiliar, work through Write a functional environment before attempting the project.

Build in stages

1. Test environment and rollout semantics

Check transitions independently, preserve terminal rewards and label time/environment axes. Store the behavior policy that collected each action.

2. Compare updates and evaluations fairly

Audit the clipped objective for both advantage signs. Freeze the evaluation protocol, compare a simple baseline and distinguish training seeds from repeated episodes.

3. Learn and audit a value baseline

Fit a value table from retained trajectories, compare its actual masked error with independent calculations, and derive a multi-step GAE trace. Keep the final pre-reset observation and separate bootstrap and trace masks.

Try a changed condition

Make a prediction before opening the reasoning. Keep your answer and the evidence you would collect.

With discount 0.9, reward 1 and next-state value 10, compare a true terminal target with a time-limit cutoff in a continuing task.

Compare an approach

The true terminal target is 1. A cutoff that only ends data collection can retain bootstrap value, giving 1+0.9⋅10=101+0.9\cdot10=10. Use the final pre-reset observation, not a new episode’s reset observation. Declare the task semantics: a genuinely finite-horizon terminal objective can require a different contract. Lesson rl-05 checks both bootstrap modes and reset boundaries with retained observations. The actor remains a finite-horizon reward-to-go implementation.

Diagnose a likely failure

Symptom: PPO ratios always equal one after every update.

Check next: Check that old log probabilities were stored at collection rather than recomputed from the current policy.

Decide what is ready

Use policy-evaluation. Keep independent transition checks, behavior-policy identity, changed-horizon cases and paired evaluations across declared independent training seeds. Retain the fitted value table, independently recomputed error and terminal/cutoff GAE checks from stage 5.

Where to put your project code

Write your code in: projects/policy-evaluation/my_model.py (copy projects/policy-evaluation/starter/model.py first: cp projects/policy-evaluation/starter/model.py projects/policy-evaluation/my_model.py).

Verify your implementation: python3 projects/policy-evaluation/tests/check.py --stage all --impl projects/policy-evaluation/my_model.py

Run the staged project checks on your implementation in projects/policy-evaluation/my_model.py and record your transfer experiment results in your portfolio.

Open An evaluated policy in a functional environment

What still needs further work

The actor still uses sampled reward-to-go. Connecting a learned critic and GAE to actor updates, continuous actions and larger benchmark environments requires further implementation and held-out evaluation. The separate tabular critic and GAE lesson establishes their bounded mechanics.