Reinforcement Learning: Generalization and Policy Search
Tabular reinforcement learning stores one number per state, which is hopeless for backgammon or chess. This part lifts RL off the lookup table with function approximation, so that updating one state generalizes to related ones, then turns to policy search — representing and optimizing the policy directly, up to the REINFORCE policy gradient and correlated sampling.
╌╌╌╌
This builds on Reinforcement Learning, which set up learning in an unknown MDP and developed the tabular methods — passive evaluation by direct estimation, adaptive dynamic programming, and temporal differences, then active control by Q-learning and SARSA. All of those store a value per state in a table. Here we remove that restriction, first by approximating the value function and then by searching over policies directly.
Generalization in reinforcement learning
First, the scale of the problem. The tabular methods store one entry per state (or per state-action pair): fine for a grid, but backgammon has around states and chess around . No agent can visit each even once, let alone many times, so the table has to go.1
The replacement is function approximation: represent or by any compact parameterised form instead of a lookup table. The classic choice is a weighted linear combination of features (basis functions) of the state:
A backgammon utility that would need table entries might be captured by a few dozen weights — an enormous compression. More important is generalization: adjusting in response to one visited state changes the estimate at every state that shares features, so the agent extrapolates from states it has seen to states it never will. By examining a vanishing fraction of backgammon positions, a program can learn a utility that plays at human level.1
Learning the weights is online supervised regression. If is the observed reward-to-go from in the th trial, the squared error is , and gradient descent on it gives the Widrow–Hoff (delta) rule,
The temporal-difference and Q-learning targets slot straight in — replace the observed return with the bootstrapped TD target:
and the analogous update for using . This is the tabular update with the single value replaced by the whole parameter vector: one observed transition now edits every weight, and so shifts the estimate at every related state. For passive TD with a linear approximator, the parameters provably converge to the best representable fit. What matters is linearity in the parameters — the features themselves may be arbitrarily nonlinear functions of the state (a distance-to-goal term, a piece-count, a board pattern). With nonlinear approximators and active learning the guarantees disappear; the parameters can even diverge, and RL with general function approximators remains difficult to stabilize.
Policy search and policy gradients
Every method so far learns a value — a utility , an action-utility — and then reads a policy off it, greedily. Policy search turns that around. It represents the policy directly, as a parameterised function , and adjusts to raise the policy's performance. The idea is the simplest in the whole chapter: keep twiddling the policy as long as its performance improves, then stop.2
The distinction from value-based learning is substantive. Suppose we still represent the policy through Q-functions, taking the highest-scoring action, . Q-learning with function approximation tunes so that lands close to ; policy search tunes so that the resulting behaviour is good, and the two targets can be far apart. The approximate function gives exactly optimal behaviour — the same in every state — yet is nowhere near as a function. Policy search ignores the gap; only the ranking of actions the parameters induce matters.
Representing the policy
A policy maps states to actions, and — as with value approximation — we want far fewer parameters than there are states. The Q-function form above is one option: a bank of parameterised , one per action, linear in or a neural network, with . It has a fatal defect for gradient methods, though. With discrete actions the makes a discontinuous function of : at some settings an infinitesimal nudge to flips the winning action, so the policy value jumps. A jump has no useful gradient, and gradient ascent stalls.2
The remedy is a stochastic policy. Instead of committing to one action, returns the probability of choosing in . The standard choice is the softmax over the parameterised scores,
the multi-action generalisation of the logistic function. Softmax is nearly deterministic when one action's score dominates, recovering the greedy policy in the limit, but it is differentiable in everywhere — a small change in shifts the probabilities smoothly rather than snapping the choice from one action to another. Because the policy value depends continuously on those probabilities, it too becomes a differentiable function of , and gradient ascent applies again.
The objective: policy value
Let be the policy value — the expected reward-to-go when is executed. Policy search is the optimisation problem
When the policy and environment are both deterministic and is available in closed form, this is an ordinary continuous optimisation: follow the policy gradient uphill. When no closed form exists, we can still estimate by executing and averaging the return, then climb the empirical gradient — perturb each parameter a little, see how the measured value moves, and step in the improving direction. With the usual caveats this hill-climbing converges to a local optimum in policy space.2
Stochasticity is what makes this hard. Empirical hill climbing wants to compare against , but in a stochastic environment the return on any single trial swings wildly — a run of good luck or bad cards drowns the small signal from . Comparing two noisy averages is noisier still. One can beat the noise down by running many trials and using the sample variance to judge when enough have accumulated, but for problems where each trial is slow, costly, or dangerous, that is not an option.
The policy gradient
For a stochastic policy there is a better route: an unbiased estimate of read straight off the trials run at, with no perturbation and no second policy. Derive it first for a nonsequential environment, where doing action in the start state yields reward immediately. The policy value is just the expected reward, so
This is a sum over all actions, which the agent cannot compute — it only ever observes the actions it actually took. The trick is to turn the sum into an expectation under itself, so that it can be approximated by samples. Multiply and divide each term by :
where is the action taken on the th of trials. The outer factor is the very probability with which each action is sampled, so the weighted sum collapses to a plain average over the sampled trials. The true gradient is thus approximated by a sum of terms, one per trial, each the gradient of the action-selection probability scaled by the reward that action earned and normalised by how likely it was.
For a sequential environment the same reasoning applies at every state the agent visits. Writing for the total reward received from state onward on the th trial and for the action taken in on that trial,
The resulting algorithm is REINFORCE. It is usually far more effective than hill climbing that reruns many trials at each , because every trial contributes a gradient direction rather than a single noisy scalar — although it is still slower than one would like.3
- 1input: differentiable policy , step-size , discount
- 2any point in parameter space
- 3for each episode do
- 4generate a trial by executing
- 5for each visited state with action do
- 6reward-to-go
- 7one trial's gradient term
- 8
- 9until the policy value stops improving
- 10return
Two features make REINFORCE recognisable as gradient ascent on . The ratio is the gradient of — the direction in parameter space that makes the taken action more probable — and it is scaled by the return . So the rule pushes the policy to repeat actions that were followed by high reward and to avoid those followed by low reward, with the strength of the push set by how good the outcome was. Nothing in it requires a model or a value estimate; the observed return alone drives the update.
Correlated sampling and PEGASUS
The variance that plagues policy search has a clean partial fix when a simulator is available. Consider comparing two blackjack programs: play each against the dealer for many hands and compare winnings. The winnings swing with the luck of the cards, so the comparison is noisy. But if both programs play the same pre-generated deals, the card-luck cancels out of the difference, and a far smaller sample settles which program is better. This is correlated sampling: fix the random outcomes in advance and evaluate every candidate policy against the identical draws.4
This idea underlies PEGASUS, a policy-search algorithm for domains with a
simulator whose random
outcomes can be replayed. It generates random-number
sequences in advance and scores every candidate policy on that same set of
sequences. A strong guarantee follows: the number of sequences needed so that
every policy's value is estimated well depends only on the complexity of the
policy space, not on the complexity of the domain. Policy search by correlated
sampling is how reinforcement learning has flown autonomous helicopters
through manoeuvres beyond expert human pilots, over a simulator learned from
observed flight.
Policy search rounds out the chapter's third design. The utility-based agent learns a model; Q-learning and SARSA learn a value; policy search learns behaviour itself, and its gradient form — REINFORCE — is the direct ancestor of the policy-gradient methods the dedicated RL subject takes to full depth.
Deep reinforcement learning
AIMA's chapter ends where the modern field begins. It has the linear function approximator and warns that nonlinear ones lose the convergence guarantees; what it predates is the discovery of how to make a deep neural network stand in for or and still learn stably. That is deep reinforcement learning, and the two results that opened it are worth stating precisely, because each is a direct engineering answer to an instability this lesson already named. The dedicated RL subject develops both in full; this section gives the outline.
Deep Q-networks
Take the tabular Q-learning of this lesson and replace the table with a convolutional network that reads raw pixels. Trained naively, it diverges — the deadly combination the lesson flagged: nonlinear approximation, bootstrapping, and off-policy updates. Mnih and colleagues at DeepMind made it work with two additions, and the fix maps one-to-one onto the two things that break.5
- Experience replay. Store each transition in a buffer and train on random minibatches drawn from it, rather than on consecutive transitions. Consecutive samples are heavily correlated — successive frames of one game — and correlated gradients destabilize the network; replay breaks the correlation and reuses each transition many times.
- A target network. The Q-learning target uses the very weights being updated, so the target chases the estimate and can spiral. DQN computes the target from a frozen copy whose weights are held fixed for many steps and only periodically synchronized, giving the update a stationary target to descend toward.
The published result was one network, one set of hyperparameters, learning to play 49 Atari games from pixels and score at or above a human tester on about half of them.5 It is the tabular update of this lesson, generalized by a network and stabilized by two buffers.
Policy-gradient methods at scale
REINFORCE, derived above, is the seed of the second branch. Its estimator is unbiased but high-variance, and two developments tamed it into the algorithms that train today's continuous-control and language agents.
- Actor-critic methods pair the REINFORCE policy (the actor) with a learned value estimate (the critic) that supplies a low-variance baseline, so the gradient is scaled by an advantage — how much better an action did than the critic expected — rather than the raw, noisy return.
- Proximal policy optimization (PPO), from Schulman and colleagues, addresses a different failure: a policy-gradient step large enough to learn quickly can also collapse the policy. PPO clips the update so the new policy cannot move too far from the old one in a single step, trading a little theoretical purity for the stability and simplicity that made it a default for large-scale RL.6 It is the optimizer behind reinforcement learning from human feedback in modern language models.
The through-line is that none of this abandons the lesson's Bellman-and-gradient core; it engineers around the instabilities that appear when the lookup table becomes a deep network. The modern deep-RL modules of the sibling subject cover DQN, actor-critic, PPO, and the systems built on them — AlphaGo and its successors — at the depth this single AIMA lesson cannot.
Applications
The first significant learning program of any kind was Samuel's checkers player (1959), which learned a weighted linear evaluation function by a form of the TD update. Tesauro's TD-Gammon learned backgammon to world-champion level from self-play alone, its only reward the win/loss at the end of each game, a neural-network evaluation function trained by the TD rule on raw board positions.7 In control, the cart-pole (inverted-pendulum) balancing problem — jerk a cart left or right to keep a pole upright — became the standard RL benchmark, and reinforcement learning has since flown autonomous helicopters through manoeuvres beyond expert human pilots, using policy search over a simulator learned from observed flight.
Footnotes
- AIMA, §21.4 — Generalization in Reinforcement Learning: function approximation replaces the lookup table with a parameterised form (e.g. a linear combination of features), enabling generalization to unvisited states; the Widrow–Hoff/delta rule and the TD/Q-learning gradient updates fit the weights, with convergence guaranteed for linear passive TD but not for nonlinear active learning. ↩ ↩2
- AIMA, §21.5 — Policy Search: keep adjusting the policy while its performance improves; a parameterised policy (e.g. ) with far fewer parameters than states; policy search finds that performs well, not that makes resemble (the example); the discrete-action makes the policy a discontinuous function of , so methods use a differentiable stochastic policy , typically the softmax; the policy value is the expected reward-to-go, optimised by following or by empirical hill climbing, which stochasticity makes noisy. ↩ ↩2 ↩3
- AIMA, §21.5 — the policy-gradient derivation: in a nonsequential environment , rewritten by multiplying and dividing by into an expectation estimated from trials, ; the sequential generalisation uses the reward-to-go ; the algorithm is REINFORCE (Williams, 1992), more effective than repeated hill climbing but still slow. ↩
- AIMA, §21.5 — correlated sampling: pre-generate the random outcomes and evaluate every candidate policy on the same draws to cancel the shared randomness (the blackjack example); this underlies PEGASUS (Ng and Jordan, 2000) for simulator domains, whose sample requirement depends only on the complexity of the policy space, not of the domain; used for autonomous-helicopter control. ↩
- Mnih, Kavukcuoglu, Silver, et al. (2015),
Human-level control through deep reinforcement learning
, Nature 518 — the deep Q-network: a convolutional network trained by Q-learning from raw Atari pixels, stabilized by experience replay and a periodically-updated target network, reaching human-level play across 49 games with a single architecture and hyperparameter set. (Conference precursor: Mnih et al., NeurIPS Deep Learning Workshop, 2013.) ↩ ↩2 - Schulman, Wolski, Dhariwal, Radford, and Klimov (2017),
Proximal policy optimization algorithms
, arXiv:1707.06347 — PPO, which bounds each policy-gradient step with a clipped surrogate objective for stability and simplicity; it builds on trust-region policy optimization (Schulman et al., 2015). Actor-critic and advantage estimation are treated in Sutton & Barto, Reinforcement Learning: An Introduction (2nd ed., 2018), Ch. 13. ↩ - AIMA, §21.6 — Applications: Samuel's checkers program, Tesauro's TD-Gammon backgammon player learned from self-play, the cart-pole balancing benchmark, and autonomous-helicopter control by policy search over a learned simulator. ↩
╌╌ END ╌╌