Simple Algorithm
Reinforcement Learning · Fixed Point · 26 min

TD Learning in the Brain

Dopamine neurons, reward prediction errors and the evidence for TD.

Recordings from midbrain dopamine neurons in monkeys showed a strange pattern: a burst when juice arrived unexpectedly, a burst at a predictive cue once the juice was expected, and a dip below baseline when expected juice failed to arrive. In the mid-1990s, computational neuroscientists recognized it as the TD error. This lesson builds the TD model of conditioning from the Rescorla–Wagner rule, derives its signatures, and weighs three decades of tests: quantitative, causal and distributional evidence for the idea that dopamine broadcasts a reward prediction error, and the findings that challenge it.

What you’ll learn

  • Describe the three signatures of phasic dopamine responses during conditioning, and derive each from the TD error with a time-step (complete serial compound) representation.
  • Explain what the Rescorla–Wagner rule accounts for, such as blocking, and what TD adds: predictions within a trial and second-order conditioning.
  • Evaluate the main tests of the reward-prediction-error hypothesis: blocking, optogenetic unblocking, the gradual backward shift and distributional codes.
  • Summarize the challenges to the hypothesis, including value-like ramps, heterogeneous signals and retrospective causal learning, and state what the evidence does and does not show.

Three signatures

Wolfram Schultz and colleagues recorded single dopamine neurons in the midbrain of monkeys (the ventral tegmental area and substantia nigra) while the animals learned that a cue, such as a light or a sound, predicted a drop of juice. Three observations stood out, and Montague, Dayan and Sejnowski (1996) and Schultz, Dayan and Montague (1997) showed that a single quantity explains all of them: the TD error of a learner that predicts discounted future reward at every moment.

SituationResponse at the cueResponse when reward is dueTD error
Reward with no predictor (or before learning)noneburstreward not predicted: δ=r>0\delta = r > 0 at the reward
Cue reliably predicts reward (after learning)burstno changethe cue raises the prediction unexpectedly; the reward is fully predicted, δ=0\delta = 0
Cue, then the predicted reward is withheldburstdip below baseline, at the expected timeδ=−r\delta = -r exactly when the reward was due
The dip is the telling detail: it is timed to when the reward should have arrived, so the neurons carry a learned prediction of timing, not just of amount.

From Rescorla–Wagner to TD

The psychology of conditioning had already put prediction errors at the center. In the Rescorla–Wagner model (1972), each cue ii present on a trial has an associative strength ViV_i, and after the trial

ΔVi=αi(λ−∑j presentVj),\Delta V_i = \alpha_i\Big(\lambda - \sum_{j\,\text{present}}V_j\Big),

where λ\lambda is the reward obtained. Learning is driven by the trial-level error between what happened and what all present cues predicted. That explains blocking (Kamin, 1969): once cue A predicts the reward, training the compound AB with the same reward produces no error, so B learns almost nothing.

But a trial-level rule cannot say when within a trial the reward is expected, so it has no account of the timed dip. And it cannot produce second-order conditioning, in which a cue B followed by an already-trained cue A, with no reward at all, comes to be valued: on those trials λ=0\lambda = 0, so Rescorla–Wagner can only lower B's strength. The TD model (Sutton & Barto, 1990) makes a prediction at every moment and uses the next moment's prediction as part of the target, δt=rt+1+γV(xt+1)−V(xt)\delta_t = r_{t+1} + \gamma V(x_{t+1}) - V(x_t): a reward-predicting cue is itself a source of prediction error, which gives second-order conditioning for free.

DerivationThe signatures from the TD error
  1. V(xt)=γ T−1−t r,t=0,…,T−1V(x_t) = \gamma^{\,T-1-t}\,r,\qquad t = 0, \dots, T-1

    Represent time within a trial by a complete serial compound: one state xtx_t for each step t=0,1,…,T−1t = 0, 1, \dots, T-1 after cue onset, with reward rr arriving on leaving xT−1x_{T-1} and a value of 0 afterwards. Between trials the cue can come at any moment, so the inter-trial state has value 0. After learning, the values are the discounted reward to come:

  2. δcue=γV(x0)−0=γTr>0,δdelay=γ γT−2−tr−γT−1−tr=0,δreward=r+0−r=0\delta_{\text{cue}} = \gamma V(x_0) - 0 = \gamma^{T}r > 0,\qquad \delta_{\text{delay}} = \gamma\,\gamma^{T-2-t}r - \gamma^{T-1-t}r = 0,\qquad \delta_{\text{reward}} = r + 0 - r = 0

    At cue onset the agent moves from the inter-trial state (value 0) to x0x_0 with no reward. During the delay consecutive predictions agree. At the reward the reward exactly matches the prediction:

  3. δomitted=0+0−V(xT−1)=−r\delta_{\text{omitted}} = 0 + 0 - V(x_{T-1}) = -r

    Omission: on leaving xT−1x_{T-1} no reward comes, so the error is negative, at exactly the time the reward was due. Before learning (V≡0V \equiv 0) the only error is δ=r\delta = r at the reward.

Predict before you look

A reward of 1 arrives 3 steps after cue onset (T=3T = 3), with γ=0.9\gamma = 0.9. After learning, what is the TD error at cue onset?

Show the answer

0.729

V(x2)=1V(x_2) = 1, V(x1)=0.9V(x_1) = 0.9, V(x0)=0.81V(x_0) = 0.81, and the jump from the inter-trial state gives δ=γV(x0)−0=0.93=0.729\delta = \gamma V(x_0) - 0 = 0.9^3 = 0.729. The model predicts that responses to cues shrink as the delay to reward grows, and dopamine cue responses do decrease with longer delays (Kobayashi & Schultz, 2008), a pattern read as temporal discounting.

python
import numpy as np

T, gamma, alpha, trials = 5, 0.9, 0.2, 60   # reward 5 steps after the cue
V = np.zeros(T + 1)                 # V[t]: value t steps after cue onset; V[T] = 0 after the reward
deltas = np.zeros((trials, T + 1))  # column 0: cue onset; column t + 1: the step leaving V[t]
for n in range(trials):
    deltas[n, 0] = gamma * V[0]     # from the inter-trial state (value 0) to cue onset
    for t in range(T):
        r = 1.0 if t == T - 1 else 0.0
        delta = r + gamma * V[t + 1] - V[t]
        deltas[n, t + 1] = delta
        V[t] += alpha * delta

TD(0) on a complete serial compound. Each row of deltas is one trial's TD errors over time. In the first trial the only error is at the reward. Over trials the bump travels backward through the delay steps (with these settings its peak sits at an intermediate step from trial 6 to trial 18) and settles at cue onset, at height γ5≈0.59\gamma^5 \approx 0.59, while the error at the reward fades to 0. This gradual backward shift is a specific prediction of TD with a time-step representation.

Testing the hypothesis: quantitative, causal, distributional

Correlation with a TD error is not proof. Over the following decades the hypothesis was tested in increasingly demanding ways.

  • Graded errors. When cues predicted reward with different probabilities, dopamine responses to the cue grew with the probability and responses to the reward shrank with it, as graded prediction errors should (Fiorillo, Tobler & Schultz, 2003).
  • Blocking. In a blocking design, dopamine neurons came to respond to a normally trained control cue but responded little to the blocked cue, mirroring the behavior (Waelti, Dickinson & Schultz, 2001).
  • Causation. Steinberg et al. (2013) trained rats in a blocking design, where the reward is already predicted and the added cue is normally not learned, and optogenetically stimulated dopamine neurons at the moment of reward, mimicking a prediction error. The rats then learned about the blocked cue ("unblocking"). Stimulation timed to omitted rewards also slowed extinction. Brief, error-like dopamine activity is therefore sufficient to drive cue learning.
  • The backward shift. TD with a time-step code predicts that during learning the error moves gradually from the reward back to the cue, as in the simulation above. For years recordings showed mostly changes in amplitude, not a traveling bump; Amo et al. (2022) reported the gradual temporal shift in mice, in dopamine neuron activity and in striatal dopamine release, and argued that whether it appears depends on the task design and the learning strategy.
  • Derivative-like signals. Kim et al. (2020) moved mice through virtual-reality tracks with teleports and speed changes; dopamine signals jumped and dipped like the temporal difference of a value function, which gave a single TD account of both brief bursts and slow ramps.
Check your understanding

What did optogenetic unblocking (Steinberg et al., 2013) add to the earlier recordings?

  1. It showed that dopamine neurons fire when rewards are unexpected
  2. It proved that dopamine is the only signal that drives learning
  3. It showed that dopamine neurons encode the full distribution of rewards
  4. It showed that artificially producing error-like dopamine activity at reward time is enough to make animals learn about a cue they would otherwise ignore
Show the answer

D. It showed that artificially producing error-like dopamine activity at reward time is enough to make animals learn about a cue they would otherwise ignore

Recordings show correlation. Stimulating the neurons exactly when a natural prediction error would occur, in a design where none occurs, and observing learning, shows causal sufficiency. It does not show necessity for every kind of learning, nor that dopamine carries nothing else.

Debates and alternatives

The prediction-error hypothesis is the most widely used account of phasic dopamine, with quantitative and causal support. Its scope is contested.

  • Value or error? Dopamine release in the striatum can ramp up as an animal approaches a reward, which looks more like a value signal than a brief error (Howe et al., 2013; Hamid et al., 2016), and release and spiking can dissociate (Mohebi et al., 2019). TD accounts exist for ramps, for instance as temporal differences of a convex value function (Kim et al., 2020) or as a consequence of state uncertainty (Mikhael et al., 2022), but whether they explain all ramping data is debated.
  • Many signals. Dopamine neurons also respond to sensory features, movement and other task variables, and different populations respond differently (Engelhard et al., 2019). Generalized prediction-error accounts can absorb some of this, by predicting features as well as rewards.
  • Retrospective causal learning. Jeong et al. (2022) proposed that animals learn by looking back from a reward to its likely causes, formalized as an adjusted net contingency for causal relations (ANCCR). In experiments designed to separate the two accounts, they reported that mesolimbic dopamine release behaved as ANCCR's learning signal predicts and not as an RPE, and presented this as a challenge to the dominant theory. Defenders of TD reply that ANCCR does not naturally reproduce derivative-like signals or the probability-scaled omission dips that TD explains, that the TD variants tested were narrow, and that suitably specified TD models can reproduce some of the reported data (Uchida, 2024, in an essay for The Transmitter). More broadly, Gershman et al. (2024) argue that a generalized prediction-error account handles ramps, sensory and motor responses and effects on action, while acknowledging findings that seem to need more than prediction errors.

What the evidence does and does not show, as of the mid-2020s: brief dopamine signals in many tasks track a temporal-difference prediction error with remarkable precision, including its timing, graded size and distributional structure, and producing such signals artificially can drive learning. It does not show that dopamine is a TD error everywhere, that the brain's state representation is a simple time-step code, or that prospective TD learning is the only learning mechanism the signal supports. "Dopamine reports a TD error" is best treated as a powerful, well-tested approximation whose boundaries are being mapped.

Key takeaways

  • Phasic dopamine responses show three signatures (bursts to unpredicted rewards, transfer of the burst to predictive cues, timed dips when predicted rewards are omitted) that match the TD error of a moment-by-moment value predictor.
  • Rescorla–Wagner explains blocking with a trial-level prediction error; TD extends it to predictions within a trial, producing timed omission dips and second-order conditioning.
  • The hypothesis passed demanding tests: graded and blocked responses, optogenetic unblocking (sufficiency), a gradual backward shift during learning, and a distributional code whose neuron-by-neuron asymmetries predict their reversal points.
  • Its scope is contested: value-like ramps in release, heterogeneous responses, and retrospective causal accounts such as ANCCR. "Dopamine reports a TD error" is a well-tested approximation, not a settled identity.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

After learning, a cue is followed by no reward. What does the TD model with a time-step representation predict for the dopamine signal?

  1. No change at any time, because no reward arrived
  2. A dip right after the cue
  3. A burst at the cue and a dip below baseline exactly when the reward was due
  4. A dip spread evenly over the whole delay
Show the answer

C. A burst at the cue and a dip below baseline exactly when the reward was due

The cue still raises the prediction, giving a positive error at cue onset. Predictions agree through the delay, and on leaving the last step the expected reward rr fails to arrive: δ=0+0−r=−r\delta = 0 + 0 - r = -r, a pause timed to the expected reward. That timing is why the dip is strong evidence that the neurons carry a learned temporal prediction.

Question 2

Cue A has been paired with food. Now cue B is repeatedly followed by A, with no food, and B comes to elicit anticipation. Which model accounts for this second-order conditioning?

  1. Rescorla–Wagner, because B is followed by a cue that predicts reward
  2. TD learning, because the arrival of A raises the prediction, so it produces a positive error that teaches B
  3. Neither: learning requires a primary reward on the same trial
  4. Both equally, since both are prediction-error rules
Show the answer

B. TD learning, because the arrival of A raises the prediction, so it produces a positive error that teaches B

In TD, the target includes the next prediction: when A appears, γV(A)−V(B)>0\gamma V(A) - V(B) > 0 even without food, so B gains value. Rescorla–Wagner's error compares the trial's reward (λ=0\lambda = 0 here) with the cues' total prediction, so it can only push B's strength down, toward conditioned inhibition.

Question 3

Which finding of Dabney et al. (2020) supports a distributional code rather than a single scalar prediction error?

  1. Dopamine neurons respond more to larger rewards
  2. Dopamine neurons dip when rewards are omitted
  3. Different neurons had reliably different reversal points, and each neuron's asymmetry between positive and negative errors predicted its reversal point
  4. Dopamine release ramps up as the reward approaches
Show the answer

C. Different neurons had reliably different reversal points, and each neuron's asymmetry between positive and negative errors predicted its reversal point

A single scalar error predicts the same reversal point (the mean reward) for every neuron. Reliable diversity, explained by each neuron's asymmetric scaling, is what distributional TD with expectile-like channels predicts, and it allowed the authors to decode a multimodal reward distribution from the population.

Question 4

Which statement best summarizes the evidence on dopamine and TD errors as of the mid-2020s?

  1. Dopamine has been shown to be exactly a TD error in all brain regions and tasks
  2. Phasic dopamine signals often track TD errors closely and can causally drive learning, but the scope of the hypothesis (release versus firing, ramps, heterogeneity, retrospective accounts) is debated
  3. The TD hypothesis was refuted by the discovery of ramping dopamine signals
  4. Dopamine encodes reward value only, never prediction errors
Show the answer

B. Phasic dopamine signals often track TD errors closely and can causally drive learning, but the scope of the hypothesis (release versus firing, ramps, heterogeneity, retrospective accounts) is debated

The core signatures, graded errors, causal unblocking and distributional structure support the hypothesis; ramps, heterogeneous responses and ANCCR-style results challenge its scope. The debate is about boundaries and mechanisms, not about whether the correspondence exists.

Further reading

  • W. Schultz, P. Dayan & P. R. Montague, "A neural substrate of prediction and reward," Science 275, 1593–1599 (1997).
  • P. R. Montague, P. Dayan & T. J. Sejnowski, "A framework for mesencephalic dopamine systems based on predictive Hebbian learning," Journal of Neuroscience 16(5), 1936–1947 (1996).
  • E. E. Steinberg, R. Keiflin, J. R. Boivin, I. B. Witten, K. Deisseroth & P. H. Janak, "A causal link between prediction errors, dopamine neurons and learning," Nature Neuroscience 16, 966–973 (2013).
  • W. Dabney, Z. Kurth-Nelson, N. Uchida, C. K. Starkweather, D. Hassabis, R. Munos & M. Botvinick, "A distributional code for value in dopamine-based reinforcement learning," Nature 577, 671–675 (2020).
  • H. Jeong, A. Taylor, J. R. Floeder, M. Lohmann, S. Mihalas, B. Wu, M. Zhou, D. A. Burke & V. M. K. Namboodiri, "Mesolimbic dopamine release conveys causal associations," Science 378, eabq6740 (2022).