Successor Representations (UC Berkeley CS 285)

Learn once where a policy goes. Then the value of any new reward is one dot product per cell, with zero new experience. On our 31-cell grid, GPI combines three stored policies and reaches the optimal average value, 7.39, for a reward none of them learned.

Learn the successor representation: a map of where a policy spends its future. It turns a new reward into a value, and a new policy, at once.

Pick Successor map and tap a cell to see where the random walk goes from there. Pick Value and tap cells to place rewards: the values change at once. Pick GPI to see three stored policies share the work. Then we build, piece by piece, distances, the map, its backup, features, transfer and C-learning.

You need the value function and its Bellman equation (Q-learning) and goal-conditioned values (Multi-task and goal-conditioned RL). We build the rest from zero.

A supplement to UC Berkeley CS 185/285, Deep Reinforcement Learning, Sergey Levine (Spring 2026). It follows Part 4 of Lecture 24, multi-task and hierarchical RL (PDF). The words, toys and numbers here are our own.

Read the future, then price it

Illustrative toy: a 6 × 6 grid with a wall in column 2 (31 open cells), gamma 0.9, a uniform random walk for the map. Cells are (row, column) from (0, 0) at the top left. The stored policies head for three corners (top left, top right, bottom right), with 10% random moves.

Chapter 0

The Reward Moved

Move a reward and count what a model-free learner must pay to catch up

A delivery robot learns the value of each spot in a warehouse for one drop-off point. Then the drop-off point moves. A model-free learner throws its values away and collects new experience. The robot's habits did not change. Only the reward did.

The course asks a sharp question: what is the smallest model that lets you evaluate a policy? A full model predicts the next state. For evaluation you need less: where the policy goes in the future, and how often. That map is the successor representation (SR), from Dayan (1993).

Move the reward: relearn or reuse

Left: TD learning rebuilds the values from new steps of experience. Right: the successor map prices the new reward at once. Pick a reward, then press Relearn.

Illustrative: the hero's grid and random walk, TD(0) with step size 0.05 on one long walk. The reward is 1 per step on a reward cell. "Within 10%" means the largest error is under a tenth of the largest true value.

TD needs thousands of new steps. The SR needs none, because it keeps the part that did not change: the policy's future. It sits between the two families of RL.

ApproachWhat it storesWhen the reward changes
Model-free (V or Q)one number per state, for one rewardrelearn from new experience
Successor representationwhere the policy goes, for any rewardone dot product per state
Full modelthe next-state chances p(s′|s,a)plan again

The failure. The SR belongs to one policy. If the robot's habits change, the map is stale. Measure it: compare the map's predicted value with real returns. Chapter 5 shows how to improve a policy anyway.

  1. Values as distances: goal-conditioned values count steps and obey a triangle inequality.
  2. The successor representation: swap two sums in V-pi and a map falls out.
  3. The SR's Bellman backup: learn the map by TD.
  4. Successor features: a few features in place of every state.
  5. Transfer with GPI: combine stored policies for a new reward.
  6. C-learning: the map as a classifier, for continuous states.
  7. The field guide: terms, numbers, code and the credit.
The reward moves but the policy stays the same. What can the successor representation reuse?

Chapter 1

Goal-Conditioned Values Are Distances

Charge one point per step, read the value as a step count, and plan through a waypoint

A goal-conditioned value V(s,g) says how good state s is for reaching goal g (Multi-task and goal-conditioned RL, Chapter 3). Pick one reward: minus 1 for every step not at the goal. Set the discount gamma to 1 and end the episode at the goal.

Say it aloud

V of s and g equals minus one plus the expected V of s-prime and g, if s is not g. It is zero if s is g.

V(s,g)
V of s and g the value of state s when the goal is g.
−1
minus one the cost of one step away from the goal.
Es′
the expected value over s-prime the average over the next state.
V(s′,g)
V of s-prime and g the value one step later, same goal.
0
zero at the goal the episode ends, so nothing more is paid.
In plain words

Pay 1 for each step until you reach g. Unroll it and V(s,g) is minus the number of steps from s to g.

With numbers

On our grid, cell (4, 0) to cell (4, 4) is 12 steps: 4 up, 4 across the top, 4 down. So V = −12.

Write d(s,g) = −V(s,g) for the step count of the best policy. A detour through any waypoint w is one way to reach g, so it can only cost as much or more.

Say it aloud

V of s and g is at least V of s and w plus V of w and g.

V(s,g)
V of s and g minus the steps on the best route from s to g.
V(s,w)
V of s and w minus the steps from s to the waypoint w.
V(w,g)
V of w and g minus the steps from w to g.
In plain words

Add the two legs through w. The total is never better than going straight. It ties when w lies on a best route.

With numbers

From (4, 0) to (4, 4): through (0, 2) the legs are −6 and −6, a tie at −12. Through (5, 5) they are −14 and −2: −16, 4 steps worse.

Route through a waypoint

Each cell shows minus its step count to the goal g. Choose what a tap moves, then tap a cell.

Step counts by breadth-first search on the hero's grid; moves are up, down, left and right.

This is why the course calls goal-conditioned RL "a lot like a model": V(s,g) tells you how easy each state is to reach. A planner can search over waypoints that maximise V(s,w) + V(w,g) (Nasiriany et al.). The inequality can also serve as an extra loss on the value network.

The failure. A learned V can break the inequality, so a planner trusts a shortcut that does not exist. Measure it: sample triples (s, w, g) and count the violations. Fix it with that count as a penalty in training.

V(s,g) = −10. Through waypoint w, V(s,w) = −4 and V(w,g) = −9. What does that say about w?

Chapter 2

The Successor Representation

Swap two sums in the value function and pull out a map of where the policy goes

Take a reward that depends only on the state, r(s). The value of state st under policy π adds the reward of every future step t′, discounted by gamma. Each future reward is an average over where you might be at step t′. Group the terms by state instead of by time. Each state s then collects one weight: how often you stand there, discounted.

Say it aloud

p-pi of s-future equals i, given s-t, equals one minus gamma, times the sum over t-prime of gamma to the t-prime minus t, times p of s-t-prime equals i.

pπ(sfuture = i | st)
p-pi of s-future equals i the share of the discounted future that policy π spends in state i.
1 − γ
one minus gamma scales the weights so they add up to 1.
Σt′=t∞
the sum over t-prime one term for every future step, starting now.
γt′−t
gamma to the t-prime minus t the discount for waiting that many steps; gamma is 0.9 here.
p(st′ = i | st)
the chance of being at i at step t-prime starting from s-t and following π.
In plain words

For each future step, take the chance of being in state i. Shrink it by gamma once per step of delay. Add them all, then multiply by one minus gamma.

With numbers

With made-up numbers: two states. From A you always go to B. From B you stay or go back to A, half and half. At gamma 0.9, the share of B in A's future is 0.621, and A's share is 0.379. They sum to 1.

Stack these shares for every state i into one vector, μπ(st). That vector is the successor representation of st. The value is now a weighted sum.

Say it aloud

V-pi of s-t equals mu-pi of s-t, transposed, times r, over one minus gamma.

Vπ(st)
V-pi of s-t the value of s-t under π.
μπ(st)T
mu-pi of s-t, transposed the successor map of s-t: one share per state, 31 here.
r
r the reward vector, one reward per state.
1/(1 − γ)
over one minus gamma undoes the scaling; 10 at gamma 0.9.
In plain words

Multiply each state's share by its reward. Add them. Divide by one minus gamma.

With numbers

In the two-state toy, reward 1 in B only: V(A) = 0.621 × 1 / 0.1 = 6.21. Solving the Bellman equation directly gives the same 6.21.

Stretch the map with gamma

Teal shows μ(s) for the outlined cell under the random walk. Tap a cell, then drag gamma.

0.90

Exact maps: μ = (1 − γ)(I − γPπ)−1 on the hero's illustrative grid.

At low gamma the map hugs the cell. At high gamma it spreads through the doorway. The average look-ahead is gamma/(1 − gamma) steps: 9 at gamma 0.9.

The failure. A tabular map needs |S| numbers per state, so |S|² in all. For images that is hopeless. Measure your state count before you choose a table. Chapters 4 and 6 are the fixes.

At gamma 0.9, a state's successor map puts 0.3 on cell X and 0.7 on cell Y. Rewards are 2 at X and 0 at Y. What is its value?

Chapter 3

The SR Has Its Own Bellman Backup

Split off the first step of the sum and learn the map by TD, one transition at a time

The sum in Chapter 2 runs to infinity. Nobody computes it directly. Pull out the step t′ = t. What is left is the same sum, started one step later, times gamma.

Say it aloud

mu-i of s-t equals one minus gamma times delta of s-t equals i, plus gamma times the expected mu-i of s-t-plus-one.

μi(st)
mu-i of s-t entry i of the map of s-t: the share of the future spent in i.
1 − γ
one minus gamma the weight of the present step, 0.1 here.
δ(st = i)
delta of s-t equals i 1 if you stand in i now, else 0.
γ
gamma the discount, 0.9.
Eat~π, st+1~p
the expected value over the action and next state act by π, then let the world move.
μi(st+1)
mu-i of s-t-plus-one the same entry of the next state's map.
In plain words

It is a Bellman backup whose "reward" is one minus gamma when you stand in i. Do it for all 31 entries i at once: one vector update per transition.

With numbers

The two-state toy, entry B of A's map: A is not B, so the first term is 0. Then 0.9 × μB(B) = 0.9 × 0.690 = 0.621, the value from Chapter 2.

The TD version replaces the average with one sampled transition from s to s′. With step size α, move the whole row toward the target.

μ̂(s) ← μ̂(s) + α [ (1 − γ) es + γ μ̂(s′) − μ̂(s) ]

Here es is the vector with 1 at s and 0 elsewhere. From a map of zeros, one step from A to B with α = 0.5 gives μ̂(A) = (0.05, 0). In matrix form the exact answer is (1 − γ)(I − γPπ)−1, the evaluation operator of RL theory, Chapter 1.

Learn the map from transitions

Left: the TD map of the outlined cell. Right: the exact map. Below: the largest error as experience grows. Press Learn.

Illustrative: one long random walk on the hero's grid, α = 0.1, gamma 0.9, every row updated by the TD rule above.

The failure. TD noise does not vanish with a fixed step size; the error stalls at a floor. Measure the error curve, as above. Fix it with a step size that decays, or by averaging the last updates.

In the SR backup, what plays the role of the reward for entry i?

Chapter 4

Successor Features

Track a few features in place of every state, and turn three weights into a value map

Suppose the reward is a weighted sum of a few features φj(s), such as "in the left room": r(s) = φ(s)Tw. Then you do not need the share of every state. You need the discounted total of each feature along the future. That total is the successor feature ψj. Here is the Q-like version, which also takes the first action.

Say it aloud

psi-j of s and a equals phi-j of s, plus gamma times the expected psi-j of s-prime and a-prime.

ψj(s,a)
psi-j of s and a the discounted total of feature j if you take a in s, then follow π.
φj(s)
phi-j of s feature j of the current state; here 1 or 0.
γ
gamma the discount, 0.9.
Es′~p, a′~π
the expected value over s-prime and a-prime the world moves, then π picks the next action.
ψj(s′,a′)
psi-j of s-prime and a-prime the same total, one step later.
In plain words

The SR backup again, with the feature φ-j as the "reward". Choose φ-i to be one minus gamma when s is i, and you get the SR back.

With numbers

The two-state toy with features "in A" and "in B": ψ(A) = (3.79, 6.21). Each entry is A's map share divided by 0.1.

The value follows in one line, because sums and weights commute.

Say it aloud

Q-pi of s and a equals psi-pi of s and a, transposed, times w, when r of s equals phi of s transposed times w.

Qπ(s,a)
Q-pi of s and a the value of taking a in s, then following π.
ψπ(s,a)T
psi-pi of s and a, transposed the successor features: 3 numbers here.
w
w the reward weights, one per feature.
r(s) = φ(s)Tw
r of s equals phi of s transposed w the condition: the reward is a weighted sum of the features.
In plain words

Multiply each successor feature ψ-j by its weight w-j and add. A new w gives a new Q with no new learning.

With numbers

Toy, with weights w = (2, 1): V(A) = 2 × 3.79 + 1 × 6.21 = 13.79. Solving the Bellman equation for rewards (2, 1) also gives 13.79.

Turn three weights into a value map

Three features: left room, right room, top row. Drag the weights w and watch V = ψTw. Then ask for a reward in one corner.

0.20
1.00
0.00

Illustrative: the hero's grid and random walk. ψ = (I − γPπ)−1Φ is exact here; a network would learn it by the backup above.

The win is size: 3 numbers per state in place of 31. If the features are few, learning ψ is much easier.

The failure. A reward outside the span of the features gets the best fit, not the truth. Ask for the corner reward above: the fit spreads it over the right room. Measure the fit error of w on reward samples. Fix it with richer features.

ψ(s) = (4, 1, 0) and the new task has w = (0.5, 2, 3). What is V(s)?

Chapter 5

Transfer: One Improvement Step or GPI

Fit the weights of a new reward, then act greedily on one stored policy, or on the best of many

A new task arrives as reward samples {si, ri}. Successor features turn them into a policy in three steps. First, fit the weights.

Say it aloud

w gets the argmin over w of the sum over i of phi of s-i transposed w, minus r-i, squared.

w
w the reward weights of the new task.
argminw
the argmin over w the w that makes what follows smallest.
Σi
the sum over i one term per reward sample.
φ(si)Tw
phi of s-i transposed w the reward the weights predict for state s-i.
ri
r-i the reward observed in sample i.
In plain words

Find the weights whose predicted rewards miss the observed rewards by the least, in squared error. This is linear regression.

With numbers

With made-up samples: features (1, 0) with reward 2, (0, 1) with 1, and (1, 1) with 3. The fit is w = (2, 1), with zero error.

Second, Qπ = ψπTw. Third, act greedily: π′(s) = argmaxa Qπ(s,a). That is one step of policy iteration. It beats π, but it is not optimal, because Qπ assumes you follow the old π afterwards.

Store successor features for several policies πk and you can do better. Generalized policy improvement (GPI, Barreto et al.) takes the best of them, in each state.

Say it aloud

pi-prime of s equals the argmax over a of the max over k of psi-pi-k of s and a, transposed, times w.

π′(s)
pi-prime of s the new policy's action in state s.
argmaxa
the argmax over a the action that makes what follows largest.
maxk
the max over k the best of the stored policies, for this state and action.
ψπk(s,a)Tw
psi-pi-k of s and a, transposed, w Q of policy k on the new reward.
In plain words

For each action, ask every stored policy what it would earn afterwards. Keep the best answer. Pick the action with the best kept answer.

With numbers

With made-up values in one state: policy 1 gives Q = (3, 1) for actions (a1, a2), policy 2 gives (2, 4). The max over k is (3, 4), so GPI picks a2, worth at least 4. Improving on policy 1 alone picks a1.

Combine stored policies for a new reward

Arrows show GPI's action, coloured by the stored policy that wins there. Bars compare average values. Pick a reward, then switch policies off.

Illustrative toy: rewards of 1 per step on the rewarded corners ("Half and one" puts 0.5 on the top left). Values are exact, averaged over the 31 cells. "One step" improves the best stored policy alone.

GPI's promise: the new policy does at least as well as every stored policy, in every state. In the toy, "Two corners" gives GPI the optimum. "Half and one" leaves it a hair below.

The failure. If no stored policy goes near the reward, every Q is near zero and GPI picks almost at random. Measure the largest stored Q on the new reward. If it is tiny, learn a new policy.

In one state, policy 1 gives Q = (5, 2) and policy 2 gives (1, 6) for actions (a1, a2). What does GPI pick?

Chapter 6

C-Learning: The SR as a Classifier

Tell real future states from random ones, and read the successor density off the classifier

In a continuous state space, the target δ(st = i) is zero for every sampled state: you never land exactly on i. C-learning (Eysenbach, Salakhutdinov and Levine, 2020) turns the problem into classification.

Build two piles of candidate future states. Positives D+ come from the real future of (st, at). Negatives D− are any states the policy visits, drawn from pπ(s). With equal piles, the best classifier gives this chance that a candidate is a real future, F = 1.

Say it aloud

p of F equals one, given s-t, a-t and s-f, equals p-pi of s-f given s-t and a-t, over that plus p-pi of s-f.

p(F=1 | st,at,sf)
p of F equals one the classifier's chance that the candidate s-f is a real future.
pπ(sf | st,at)
p-pi of s-f given s-t and a-t the successor density: the continuous SR.
pπ(sf)
p-pi of s-f how often the policy visits s-f at all.
In plain words

The classifier compares two densities at s-f: how likely s-f is as a real future, and how likely as a random visit.

With numbers

With made-up densities 0.3 and 0.1 at s-f, p(F=1) = 0.3 / 0.4 = 0.75.

Divide p(F=1) by p(F=0) and the shared denominator cancels. Multiply by pπ(sf), which does not depend on st or at.

Say it aloud

p-pi of s-f given s-t and a-t equals p of F equals one over p of F equals zero, times p-pi of s-f.

pπ(sf | st,at)
p-pi of s-f given s-t and a-t the successor density we want.
p(F=1|·) / p(F=0|·)
the odds the classifier's chance of "real future" over its chance of "random".
pπ(sf)
p-pi of s-f the visit density, a constant for every s-t and a-t.
In plain words

Read the odds off the classifier. Multiply by how often the policy visits s-f. That is the successor density.

With numbers

Odds 0.75 / 0.25 = 3. Times 0.1 gives 0.3: the density we started with.

How do you sample a real future? The SR weighs step t + Δ by (1 − γ)γΔ. So draw the gap Δ from that distribution and take the state Δ steps ahead in a trajectory.

Say it aloud

P of Delta equals k equals one minus gamma, times gamma to the k, for k from zero up.

P(Δ = k)
P of Delta equals k the chance that the gap to the sampled future is k steps.
1 − γ
one minus gamma the chance to stop at each step, 0.1 here.
γk
gamma to the k the chance to keep going k times.
In plain words

At each step, flip a coin that stops with chance one minus gamma. The number of steps before it stops is Δ. The course writes Δ ~ Geom(γ).

With numbers

At gamma 0.9: P(Δ = 0) = 0.1, P(Δ = 1) = 0.09. The mean gap is gamma/(1 − gamma) = 9 steps.

Train the classifier, read the map

A 12-cell chain, start at cell 2. Teal outlines: the exact map. Grey bars: odds times p(sf). Press Train.

Illustrative: moves right 0.5, left 0.4, stay 0.1, gamma 0.9. Episodes start at a random cell and last 20 steps. One logit per cell for this start state, cross-entropy, a step size that starts at 0.05 and shrinks. We fold the action into the policy.

This version is on-policy: D+ comes from π's own futures. The paper also derives an off-policy version.

The failure. Where the policy rarely visits, D− has few samples and the odds are noisy. Measure how many negatives each region gets. Fix it with more varied start states.

The classifier says 0.8 for a candidate sf, and pπ(sf) = 0.05. What is the successor density there?

Chapter 7

The Field Guide

Keep the terms, the numbers, the checks and the code in one place

One idea runs through the lesson. Store where a policy goes, separate from what it earns. Then a new reward costs a dot product, and several stored policies combine through GPI.

TermWhat it isNumber to remember
Goal value V(s,g)minus the step count, reward −1, gamma 1(4, 0) to (4, 4): −12; via (5, 5): −16
Successor map μ(s)discounted share of the future in each state; sums to 1two-state toy: (0.379, 0.621)
Value from the mapV = μTr / (1 − γ)0.621 / 0.1 = 6.21
SR backup"reward" (1 − γ) in state i0.9 × 0.690 = 0.621
Successor features ψdiscounted feature totals; Q = ψTww = (2, 1): 13.79
GPIargmax over a of max over k of Qπktoy, two corners: 7.39, the optimum
C-learningSR = classifier odds × pπ(sf)odds 3 × 0.1 = 0.3
Future gap ΔP(Δ = k) = (1 − γ)γkmean 9 steps at gamma 0.9

Checks before you trust a successor model

The core in code

pythonimport numpy as np

def successor_map(P_pi, gamma):
    # P_pi: [S, S] next-state chances under pi. Row s of M is mu(s); each row sums to 1.
    S = P_pi.shape[0]
    return (1 - gamma) * np.linalg.inv(np.eye(S) - gamma * P_pi)

def value_from_map(M, r, gamma):
    return M @ r / (1 - gamma)                  # V = mu^T r / (1 - gamma), every state

def td_update(M, s, s_next, gamma, alpha):
    target = gamma * M[s_next]
    target[s] += 1 - gamma                      # "reward" (1 - gamma) in the current state
    M[s] += alpha * (target - M[s])

def gpi_action(psi, w):
    # psi: [K, A, d] successor features of K stored policies in one state; w: [d]
    q = psi @ w                                  # [K, A]: Q of every stored policy
    return int(np.argmax(q.max(axis=0)))         # best policy per action, then best action

def future_gap(gamma, rng):
    return rng.geometric(1 - gamma) - 1          # P(k) = (1 - gamma) gamma^k, k = 0, 1, ...

# C-learning: label (s_t, a_t, s_{t+gap}) as 1 and (s_t, a_t, s ~ p_pi(s)) as 0, train a classifier C,
# then density(s_f | s_t, a_t) = C / (1 - C) * p_pi(s_f).

Keep going

Now press Present or Teach and derive from memory: the SR from V-pi, its backup, and the C-learning odds. Then go back to the hero, place two rewards, and predict which stored policy wins each room before you pick GPI.

Credit and source

This supplement follows UC Berkeley CS 185/285, Deep Reinforcement Learning, Sergey Levine (Spring 2026): the course page and Lecture 24 on multi-task and hierarchical RL, Parts 3 and 4. The lecture cites Dayan (1993) for the SR, Barreto et al. (2016) for successor features and transfer, and Eysenbach, Salakhutdinov and Levine (2020) for C-learning. The words, toys and numbers here are our own.

Successor Representations (UC Berkeley CS 285)
The course page · Lecture 24 slides · Back to Gleams