Q-learning: reinforcement learning from experience
Q-learning is a model-free reinforcement learning algorithm: it assigns values to possible actions in the agent's current state without requiring a model of the environment. It can handle stochastic transitions and rewards without adaptations. A Q value estimates the expected discounted return from an action in a given state, including subsequent rewards. In a grid maze, an exit might be worth 10 points. At a junction, moving right can receive a higher value than moving left if it reaches the exit faster. Trying both directions over time helps the agent improve its choice.
A train boarding example gives reinforcement learning a concrete measure of reward: the negative of the total time spent boarding. Entering as soon as the doors open minimizes the initial wait, but departing passengers can slow boarding. That strategy takes 0 seconds of waiting plus 15 seconds of struggling through the departing crowd. Waiting for passengers to leave takes 5 seconds initially, followed by 0 seconds of that struggle. Exploration can uncover the second strategy by chance. Its initial action has a larger cost, yet the total boarding cost is lower. The agent's goal includes potential future rewards, weighted across future steps, alongside the reward associated with its current state.
The update begins with a Q value initialized to a fixed value chosen by the programmer. The agent then selects an action, observes a reward, and enters a new state that may depend on both the previous state and the selected action. A Bellman equation combines the current value with new information through a weighted average. The new target includes the observed reward plus the discounted maximum action value in the next state. The learning rate controls the weighting of that target. An episode ends upon reaching a terminal state, although learning can also continue in tasks without episodes. Final-state values are set rather than updated and can usually equal zero.
The learning rate determines how strongly newly acquired information overrides older information. At 0, the agent learns nothing and exclusively uses prior knowledge; at 1, it considers only the most recent information. For stochastic problems, convergence requires technical conditions that include decreasing the learning rate toward zero. A constant rate such as 0.1 is nevertheless often used in practice. The guarantee of finding optimal action values in a finite Markov decision process also requires bounded rewards, suitable learning rates, and repeated sampling of every state-action pair. Exploration is therefore part of the stated guarantee for this reinforcement learning method.
The discount factor sets the importance of future rewards. A value of 0 restricts attention to current rewards, while a value approaching 1 encourages a high reward over the long term. Values at or above 1 can make action values diverge. With bounded rewards and a nonnegative factor below 1, discounted returns remain finite even when a problem contains infinite loops or paths. Neural network approximations introduce another complication: even a factor slightly below 1 can lead to error propagation and instability. In that setting, beginning with a lower discount factor and increasing it toward its final value can accelerate learning.
Initial values can also influence exploration. High starting values, called optimistic initial conditions, encourage alternatives because updating a selected action can lower its value relative to the others, increasing their chance of selection.
Tables provide the simplest storage for Q values, but more states and actions reduce the likelihood of visiting a particular combination. Standard tabular reinforcement learning here applies only to discrete state and action spaces. Function approximation extends the algorithm to larger problems, including continuous state spaces, and can generalize earlier experiences to unseen states. An artificial neural network is one option for approximating the value function. Quantization offers another route to a smaller space. Balancing a stick on a finger involves finger position and velocity, plus stick angle and angular velocity. Grouping possible values into buckets can distinguish Near from Far instead of retaining an exact distance.
Deep reinforcement learning introduces techniques for handling instability with neural networks. Correlations between observations, changes in policy and data distribution after small Q updates, and correlations between Q and target values can all contribute. Experience replay uses random samples of stored transitions, including states, actions, rewards, and subsequent states, reducing observation correlations and smoothing distribution changes. Updating target values only periodically further reduces correlations with the target. In noisy environments, using the same Q function for action selection and future-value evaluation can overestimate action values and slow learning. Double Q-learning addresses that problem with two value estimates, using one estimate to select an action and the other to evaluate it.
- Watkins and Dayan (1992): Q-learning — www.gatsby.ucl.ac.uk
- Sutton and Barto: Reinforcement Learning, An Introduction (second-edition draft) — web.stanford.edu
- François-Lavet, Fonteneau and Ernst: How to Discount Deep Reinforcement Learning — orbi.uliege.be
- van Hasselt (2010): Double Q-learning — papers.nips.cc
- Mnih et al. (2015): Human-level control through deep reinforcement learning — storage.googleapis.com