Edd's Knowledge Base

Temporal difference (TD) learning is the idea that an agent can learn from changes in its own predictions instead of waiting for the final outcome. It is the standard answer to the credit assignment problem in Reinforcement Learning, and it underlies value-based methods such as Q-Learning and the critic in Actor-Critic Methods.

The Credit Assignment Problem

Reward is not instant, actions have long-term consequences, and not all actions contribute equally to the outcome. Given a single outcome at the end (winning a chess game after 40 moves), which earlier actions deserve credit or blame? Minsky formalized this as the temporal credit assignment problem in 1961.

Supervised learningReinforcement learning
FeedbackA label per example, immediatelyA sparse scalar, often at the end
Whose fault is an error?The prediction just madeAny of many earlier actions, mixed with chance
DataIndependent examplesActions change which states come next

Reinforcing every move of a won game is noisy (a won game contains weak moves and a lost game contains good ones) and gives one thin signal for dozens of decisions. An early attempt, Minsky’s 1951 SNARC maze machine, strengthened recently active connections whenever the agent succeeded; it solved some simple mazes but nothing more complex.

Sutton’s Idea: Learn Values

In 1984, Sutton proposed maximizing the expected reward (the value) instead of the raw reward. Rewards are sparse, but expected rewards exist at every step, so there are many more chances to learn.

The value function of a state is the expected discounted total future reward from it:

If the only reward is for a win, is the probability of winning from . The discount factor makes earlier rewards count more: a reward of 10 arriving at the third future step is worth now when .

The TD Error

The learning signal is how much the value estimate changes from one step to the next:

Reinforce actions that increase the estimated value (positive ) and punish actions that decrease it (negative ). The tabular update is .

Example (chess). Before a move you estimate a 50% chance of winning. You capture the opponent’s queen and the estimate rises to 70%. The TD error is , so the queen capture is reinforced immediately, without waiting for the end of the game. What matters is the increase, not the absolute value: a move that drops the estimate from 90% to 70% is bad even though 70% is high.

Actor and Critic

TD learning has two components:

  • Critic: predicts the likelihood of reward (the value).
  • Actor: chooses actions, and is rewarded by the critic’s change in expected reward instead of the actual reward.

This split is developed in Actor-Critic Methods.

Evidence from the Brain: Dopamine

Neuroscientist Wolfram Schultz recorded dopamine neurons in monkeys that saw a visual cue and, five seconds later, received sugar water. In 1997, Dayan, Montague, and Schultz argued that dopamine encodes the reward prediction error, which is the TD error, and not the reward itself.

SituationPredictedActualErrorDopamine response
Early training, new cue, reward arrives01+1Burst at the reward
Trained, reward arrives as expected110No change at the reward; burst at the cue
Trained, cue shown, reward withheld10-1Dip below baseline at the expected reward time

After training, the cue itself is unpredictable and raises the estimated value, which is a positive TD error. The error signal has moved backward in time to the earliest reliable predictor.

Sources: Sutton & Barto, Reinforcement Learning: An Introduction. The history (Minsky 1951 and 1961, Sutton 1984) and the dopamine experiment summary follow lecture material; Dayan, Montague, and Schultz (1997) is “A Neural Substrate of Prediction and Reward”. The update rule and value definition are the standard formulation written from general knowledge. Please check the sources.