Successor Representations & Features
Splitting value into where you will go and what you will find there.
Split a value into two questions: where will I go, and what will I find there? The successor representation answers the first question once, for a policy, and then any reward function gives values with one matrix–vector product. With features it becomes successor features, which, combined with generalized policy improvement, let an agent combine old policies to act well on a new task before learning anything about it. The same idea may describe how the hippocampus represents space.
What you’ll learn
- Define the successor representation , read its rows as discounted occupancies, and factor values as .
- Derive the Bellman equation of the successor representation and its TD learning rule, and contrast reward revaluation with transition revaluation.
- Define successor features, prove the generalized policy improvement theorem, and state the transfer bound of Barreto et al. (2017).
- Describe forward–backward representations and zero-shot RL, and the evidence for SR-like representations in the brain.
Where you will go: the successor representation
The factorization separates where the policy goes from what it finds there. For (go, stay) in the two-state MDP of the value-space widget, : from the agent spends one discounted visit in , at time 0, and 9 in . With this gives . The uniform random policy moves to either state with probability ½ from both, so , and with it gives , the values found by hand in Value Functions & the Bellman Equations.
The agent keeps the policy (go, stay), but the world changes: staying in now pays instead of 2. Using the SR above, what is the new value of ?
Show the answer
-9
, with no planning at all: the SR already knows that the policy spends 9 discounted steps in . It does not say whether the policy is still a good one. It is not: staying in is now worth 10.
The SR sits between model-free and model-based methods. A model-free learner caches values, so a change of reward forces it to relearn by trial and error. A model-based learner caches one-step dynamics and must plan again. The SR caches multi-step predictions of states: a change of reward costs one product, but a change of transitions, a new wall or a moved door, invalidates the SR and must be relearned. The SR also belongs to a policy, not to the environment, which is a problem for control, where the policy keeps changing.
Learning the SR, and successor features
Split the sum at , exactly as for values. The visit at time 0 contributes the indicator of the current state; the rest is the SR of the next state, discounted:
It is a Bellman equation with a vector "reward", one entry per target state. So the SR can be learned from experience by temporal-difference learning, one TD(0) problem per column, with a vector-valued TD error:
Each column is an ordinary tabular TD(0) problem with reward , so the usual convergence results apply on-policy (Convergence of TD: Stochastic Approximation).
import numpy as np
gamma, alpha = 0.9, 0.05
P_pi = np.array([[0.5, 0.5], # uniform random policy on the two-state MDP:
[0.5, 0.5]]) # from either state, s1 or s2 with probability 1/2
r_pi = np.array([0.5, 1.0]) # expected reward of a random action in each state
M_true = np.linalg.inv(np.eye(2) - gamma * P_pi) # [[5.5, 4.5], [4.5, 5.5]]
rng = np.random.default_rng(0)
M, s = np.zeros((2, 2)), 0
for t in range(20_000):
s_next = rng.choice(2, p=P_pi[s])
target = np.eye(2)[s] + gamma * M[s_next] # indicator of s, plus a bootstrap
M[s] += alpha * (target - M[s]) # TD(0) on the whole row at once
s = s_next
print(M, M @ r_pi) # M fluctuates around M_true, and M_true @ r_pi = (7.25, 7.75)Learning the SR from one long trajectory. With a constant step size the estimate keeps fluctuating around the true SR, as tabular TD estimates do; a decaying step size would make it converge.
In large state spaces one cannot count visits to each state, but one can accumulate features. If rewards are linear in features, , then the successor features of ,
give for every (Barreto et al., 2017). They obey the Bellman equation , with the features in the role of rewards, so any TD method learns them. One-hot state features give back the SR. The vector is a task description: the same environment with different preferences.
| Pair | of = (go, stay) | of = (stay, go) |
|---|---|---|
Generalized policy improvement
Let and let act on action values. Since is greedy with respect to , for every and every next state :
Average over and add the reward: one backup with beats every 's own Bellman equation, so it beats their maximum:
By monotonicity of (Bellman Operators & Contraction), for every , and the iterates converge to the fixed point . With -accurate estimates each backup loses at most ; the constant shift adds these losses up as a geometric series, and comparing with costs one more , for in all.
Using the successor features of in the table, what is for the new task ?
Show the answer
9.1
. Directly: staying pays 1 and leaves the agent in , where goes to and stays there, worth ; so .
Zero-shot RL, and the SR in the brain
GPI over a fixed set of policies is only as good as that set. Universal successor features condition on a task vector, , so that one network covers a continuum of policies. Touati and Ollivier (2021) push this to zero-shot RL: learn, from reward-free data, representations that yield a near-optimal policy for any reward revealed afterward, with no further learning or planning. Their forward–backward (FB) representation learns maps and into such that the successor measure of a family of policies factors through them:
How well does this work? On reward-free offline datasets of continuous-control tasks, Touati, Rapin and Ollivier (2023) found that FB representations reached about 81% of the performance of supervised offline RL trained on each task, averaged over tasks and datasets (85% with a good replay buffer), while successor features depended heavily on the choice of base features: Laplacian eigenfunctions worked well, other choices inconsistently. Barreto, Hou, Borsa, Silver and Precup (2020) review how successor features and GPI combine into fast adaptation more broadly. The SR also appears in exploration: while it is being learned, the norm of a state's row grows with the number of visits to that state, so the inverse of the norm works as a count-based exploration bonus (Machado, Bellemare & Bowling, 2020). And for a random walk on an undirected graph, the SR has the same eigenvectors as the random-walk Laplacian of the graph, the kind of basis behind proto-value functions and eigenoptions.
Key takeaways
- The successor representation counts discounted future visits; its rows, scaled by , are occupancy distributions, and .
- The SR obeys the Bellman equation and is learned by TD with the indicator of the current state as the reward; it makes reward revaluation instant but must be relearned when transitions change.
- Successor features give for every reward linear in the features, so old policies can be evaluated on new tasks by dot products.
- Generalized policy improvement acts greedily on the maximum of several policies' values and is at least as good as each of them everywhere, up to ; with successor features it transfers to new tasks with a loss bounded by the distance to the nearest solved task.
- Forward–backward representations aim at zero-shot RL for any reward; the SR is also a leading model of hippocampal place cells, a hypothesis still under test.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
For the policy (go, stay), the SR has . What does that number mean?
- The agent needs 9 steps to reach from
- Starting in , the expected discounted number of visits to , , is 9
- The value of seen from
- The probability of reaching , times 9
Show the answer
B. Starting in , the expected discounted number of visits to , , is 9
The agent reaches at and stays, so the count is . Scaled by , the row becomes the discounted state distribution of the policy from .
An agent that has learned the SR of its policy faces two changes: (a) the reward in one state is doubled; (b) a door closes, so one transition now leads elsewhere. What can it update immediately?
- Both: the SR stores everything about the environment
- Neither: it must relearn from scratch in both cases
- Only (b), because transitions are stored in the SR
- Only (a): new values follow from at once, while the SR itself is invalid after (b) and must be relearned
Show the answer
D. Only (a): new values follow from at once, while the SR itself is invalid after (b) and must be relearned
The SR caches multi-step predictions of states under the old dynamics. A new reward vector is combined with it in one product. A new transition changes every row of whose future passes through the door, and those predictions must be learned again, the asymmetry Momennejad et al. (2017) tested in people.
An agent has exact action values and of two policies in the current task and acts greedily with respect to . What does generalized policy improvement guarantee?
- everywhere: at least as good as the better of the two, pair by pair
- is optimal for the current task
- equals whichever of and has the larger value at the start state
- only
Show the answer
A. everywhere: at least as good as the better of the two, pair by pair
GPI's policy can mix the two old policies state by state and beats both everywhere. In the two-state example it combined and into (stay, stay), which happened to be optimal, but optimality is not guaranteed in general.
In TD learning of the SR, what is the target for the row after the transition ?
- , the indicator of the next state
- , the indicator of the current state plus the discounted SR of the next one
Show the answer
C. , the indicator of the current state plus the discounted SR of the next one
The SR's Bellman equation is : the "reward" of a step is the indicator of the state occupied, counted at time 0. No environment reward enters; that is what lets the SR be reused across rewards.
Further reading
- P. Dayan, "Improving generalization for temporal difference learning: The successor representation," Neural Computation 5(4), 613–624 (1993).
- A. Barreto, W. Dabney, R. Munos, J. J. Hunt, T. Schaul, H. van Hasselt & D. Silver, "Successor features for transfer in reinforcement learning," Advances in Neural Information Processing Systems 30 (2017).
- A. Touati & Y. Ollivier, "Learning one representation to optimize all rewards," Advances in Neural Information Processing Systems 34 (2021).
- K. L. Stachenfeld, M. M. Botvinick & S. J. Gershman, "The hippocampus as a predictive map," Nature Neuroscience 20(11), 1643–1653 (2017).
- I. Momennejad, E. M. Russek, J. H. Cheong, M. M. Botvinick, N. D. Daw & S. J. Gershman, "The successor representation in human reinforcement learning," Nature Human Behaviour 1(9), 680–692 (2017).