Temporal-Difference Learning II and DRL Taxonomy #
One-step TD methods bootstrap after a single transition. Multi-step methods instead use several observed rewards before bootstrapping, forming a bridge between TD(0) and Monte Carlo learning.
Course Content covered in this module:
- Temporal-Difference Learning: n-step returns and TD(λ)
- Classification of Reinforcement Learning approaches, algorithms and applications:
- Model-Based versus Model-Free
- Value-Based versus Policy-Based
- On-Policy versus Off-Policy
Learning Objectives #
By the end of this module, you should be able to:
- calculate one-step, two-step and n-step returns;
- apply the n-step TD prediction update;
- explain the bias-variance trade-off created by the choice of \( n \) ;
- explain how TD(λ) combines returns of different lengths;
- describe the purpose of eligibility traces; and
- classify reinforcement learning algorithms along three independent dimensions.
1. From One-Step TD to Multi-Step TD ☆ #
TD(0) uses one observed reward and then bootstraps from the estimated value of the next state:
\[ G_{t:t+1} = R_{t+1} + \gamma V(S_{t+1}) \]Monte Carlo learning waits until the episode ends and uses the complete observed return. An n-step method lies between these two extremes:
- it observes the next \( n \) rewards;
- it then bootstraps from the estimated value of the state reached after those steps.
flowchart TD
A["TD(0): one reward"] --> B["n-step TD: several rewards"]
B --> C["Monte Carlo: complete episode"]
style A fill:#E1F5FE,stroke:#1E88E5
style B fill:#BBDEFB,stroke:#1E88E5
style C fill:#90CAF9,stroke:#1E88E5
2. The n-Step Return ☆ #
The n-step return from time \( t \) is:
\[ G_{t:t+n} = R_{t+1} + \gamma R_{t+2} + \cdots + \gamma^{n-1}R_{t+n} + \gamma^n V(S_{t+n}) \]The final term is the bootstrap estimate. If the episode terminates before step \( t+n \) , there is no successor value beyond the terminal state, so the remaining bootstrap term is zero.
Special Cases #
For \( n=1 \) :
\[ G_{t:t+1} = R_{t+1} + \gamma V(S_{t+1}) \]This is the ordinary TD(0) target.
For \( n=2 \) :
\[ G_{t:t+2} = R_{t+1} + \gamma R_{t+2} + \gamma^2V(S_{t+2}) \]As \( n \) reaches the remaining episode length, the target becomes the Monte Carlo return because no estimated successor value is needed.
3. n-Step TD Prediction ☆ #
After the n-step return becomes available, the value of the starting state is updated by:
\[ V(S_t) \leftarrow V(S_t) + \alpha \left[ G_{t:t+n}-V(S_t) \right] \]The n-step TD error is therefore:
\[ \delta_t^{(n)} = G_{t:t+n}-V(S_t) \]Unlike TD(0), the update cannot be made immediately after one transition. It becomes available after \( n \) rewards have been observed, or when the episode terminates.
Simplified Algorithm #
Initialise V(s)
For each episode:
generate experience one transition at a time
after n rewards are available:
calculate the n-step return
update the state visited n steps earlier
continue until all remaining states have been updated
4. Worked n-Step Example ☆ #
Suppose:
- \( n=3 \) ;
- rewards are \( 2, 0, 4 \) ;
- \( \gamma=0.9 \) ;
- \( V(S_{t+3})=5 \) ;
- \( V(S_t)=3 \) ;
- \( \alpha=0.1 \) .
First calculate the three-step return:
\[ \begin{aligned} G_{t:t+3} &= 2+0.9(0)+0.9^2(4)+0.9^3(5)\\ &= 2+0+3.24+3.645\\ &= 8.885 \end{aligned} \]Then update the value:
\[ \begin{aligned} V(S_t) &\leftarrow 3+0.1(8.885-3)\\ &= 3.5885 \end{aligned} \]5. Choosing n: Bias and Variance ☆ #
The choice of \( n \) determines how much the target depends on current estimates and how much it depends on sampled rewards.
| Choice | Bootstrapping | Typical bias | Typical variance | Update delay |
|---|---|---|---|---|
| Small \( n \) | More | Higher | Lower | Shorter |
| Large \( n \) | Less | Lower | Higher | Longer |
| Full return | None | Lower | Highest | Until termination |
There is no universally best value of \( n \) . It depends on the task, reward noise, quality of current estimates and acceptable update delay.
6. TD(λ): Combining Different Step Lengths ☆ #
Choosing one fixed value of \( n \) can be restrictive. TD(λ) combines one-step, two-step, three-step and longer returns using geometrically decreasing weights.
For a continuing formulation, the λ-return is:
\[ G_t^{\lambda} = (1-\lambda) \sum_{n=1}^{\infty} \lambda^{n-1}G_{t:t+n} \]The value update is:
\[ V(S_t) \leftarrow V(S_t) + \alpha \left[ G_t^{\lambda}-V(S_t) \right] \]Meaning of λ #
- \( \lambda=0 \) gives the one-step TD target.
- Intermediate values blend short and long returns.
- \( \lambda \rightarrow 1 \) gives increasing weight to longer returns and approaches Monte Carlo learning in episodic tasks.
The discount factor ( \gamma )
controls the importance of rewards over time. The trace-decay parameter ( \lambda )
controls how strongly learning credit is carried backwards across recently visited states.
7. Eligibility Traces ☆ #
The λ-return is the forward view of TD(λ): it considers a weighted mixture of future n-step returns. Eligibility traces provide the corresponding backward view, allowing values to be updated online.
The ordinary TD error remains:
\[ \delta_t = R_{t+1} + \gamma V(S_{t+1}) - V(S_t) \]For an accumulating trace:
\[ e_t(s) = \gamma\lambda e_{t-1}(s) + \mathbb{1}\{S_t=s\} \]Every state is updated according to its current eligibility:
\[ V(s) \leftarrow V(s) + \alpha\delta_t e_t(s) \]A recently visited state has a larger trace and receives more credit or blame. Its trace decays when it is not revisited.
8. Three Independent Classification Questions ☆ #
Reinforcement learning algorithms can be classified by asking three different questions:
flowchart TD
A["Reinforcement Learning Algorithm"] --> B["Uses a model?"]
A --> C["Learns values or a policy?"]
A --> D["Learns about the behaviour policy?"]
style A fill:#90CAF9,stroke:#1E88E5
style B fill:#E1F5FE,stroke:#1E88E5
style C fill:#E1F5FE,stroke:#1E88E5
style D fill:#E1F5FE,stroke:#1E88E5
These dimensions are independent. For example, an algorithm can be model-free, value-based and off-policy at the same time.
9. Model-Based versus Model-Free ☆ #
| Model-Based | Model-Free |
|---|---|
| Uses or learns environment dynamics | Learns without requiring explicit dynamics |
| Can plan using predicted transitions | Learns directly from sampled experience |
| Can evaluate hypothetical actions through the model | Must obtain useful information from interaction or stored experience |
| Examples: Dynamic Programming, planning with a learned model | Examples: Monte Carlo, SARSA, Q-learning, DQN |
The relevant model is usually represented by transition and reward information such as \( p(s',r\mid s,a) \) .
Model-free does not mean that the agent has no neural network or internal representation. It means that the algorithm does not require an explicit model of environment transitions and rewards for planning.
10. Value-Based versus Policy-Based ☆ #
Value-Based #
A value-based method learns \( V(s) \) or \( Q(s,a) \) and derives behaviour from those estimates.
Examples include SARSA, Q-learning and DQN.
Policy-Based #
A policy-based method directly parameterises and improves \( \pi_\theta(a\mid s) \) . REINFORCE is a standard example.
Actor-Critic #
Actor-Critic methods combine both ideas:
- the actor represents the policy;
- the critic estimates value and evaluates the actor’s decisions.
11. On-Policy versus Off-Policy ☆ #
| On-Policy | Off-Policy |
|---|---|
| Learns about the policy generating the behaviour | Learns about a target policy that may differ from the behaviour policy |
| Behaviour policy = target policy | Behaviour policy ≠ target policy is permitted |
| Example: SARSA | Example: Q-learning |
The distinction concerns the relationship between two policies:
- behaviour policy: generates experience;
- target policy: is evaluated or improved.
An off-policy method can explore using an \( \varepsilon \) -greedy behaviour policy while learning about a greedy target policy.
12. Classifying Common Algorithms ☆ #
| Algorithm | Model use | Main representation | Policy relationship |
|---|---|---|---|
| Dynamic Programming | Model-Based | Value-Based | Planning rather than sampled behaviour |
| On-policy Monte Carlo | Model-Free | Value-Based | On-Policy |
| Off-policy Monte Carlo | Model-Free | Value-Based | Off-Policy |
| TD(0) prediction | Model-Free | State value | Evaluates the supplied policy |
| SARSA | Model-Free | Value-Based | On-Policy |
| Expected SARSA | Model-Free | Value-Based | Usually On-Policy |
| Q-learning | Model-Free | Value-Based | Off-Policy |
| DQN | Model-Free | Value-Based | Off-Policy |
| REINFORCE | Model-Free | Policy-Based | On-Policy |
| Actor-Critic | Usually Model-Free | Value and policy | Depends on the algorithm |
Do not force every algorithm into one label. The three axes answer different questions, and some algorithm families have both on-policy and off-policy variants.
Common Mistakes ☆ #
- n-step TD does not sum only rewards; unless termination occurs, it also includes a discounted bootstrap value.
- The exponent on the bootstrap term is ( n )
, while the final sampled reward uses ( \gamma^{n-1} )
.
- A larger ( n )
does not automatically mean better learning; it changes bias, variance and update delay. #
\( \gamma \)and ( \lambda )
have different roles.
- Model-Free is not the same as Value-Based.
- On-Policy and Policy-Based are different classifications.
Practice Questions #
- Write the three-step return and identify its bootstrap term.
- Calculate an n-step TD update for a supplied reward sequence.
- Explain what happens as \( n \) grows to the remaining episode length.
- Compare the bias and variance of small and large values of \( n \) .
- Explain the meanings of \( \lambda=0 \) and \( \lambda\rightarrow1 \) .
- What information is stored by an eligibility trace?
- Classify SARSA and Q-learning along the three taxonomy dimensions.
- Why are Value-Based and On-Policy not opposite categories?
Key Takeaways ☆ #
- n-step TD observes several rewards before bootstrapping.
- TD(0) and Monte Carlo are the two ends of the multi-step spectrum.
- Small ( n )
usually means more bias and less variance; large ( n )
usually means less bias and more variance.
- TD(λ) combines returns of different lengths.
- Eligibility traces distribute each TD error across recently visited states.
- Model-Based/Model-Free, Value-Based/Policy-Based and On-Policy/Off-Policy are separate classification axes.
Checklist #
- I can calculate an n-step return.
- I can apply the n-step TD update.
- I can explain the bias-variance effect of changing \( n \) .
- I can explain the meaning of \( \lambda \) .
- I can describe eligibility traces.
- I can distinguish the three DRL taxonomy axes.
- I can classify common reinforcement learning algorithms.
References #
- Sutton and Barto, Reinforcement Learning: An Introduction, Chapters 7 and 12.
- Official Course Content for Temporal-Difference Learning II and DRL taxonomy.
- Supplied material introducing n-step TD prediction.