Intro to RL#
Machine Learning refers to the development of algorithms which learn from experience, rather than direct programming, to accomplish some task. Machine learning has three major subdivisions:
- Supervised Learning: function approximation. Learn functional mapping from input to output.
- Unsupervised Learning: data description. Learn structures present in unlabeled data.
- Reinforcement Learning: reward maximization. Learn optimal policy to maximize reward.
Reinforcement Learning (RL) involves sequential decision-making in an environment with evaluative feedback. As part of any RL system, an agent interacts with its environment to maximize some reward. The primary objective of the system is to learn the optimal policy mapping states of the environment to action choices.

Markov Decision Processes#
Definition + Components#
Markov Decision Processes (MDPs) provide a theoretical framework to represent RL problems by defining the following core components:
- : set of possible states.
- : set of possible actions.
- : distribution of reward over possible state transitions.
- : probabilistic state transition function.
- : discount factor.
The state transition function defines the distribution over possible state transitions. For example, given a starting state and selected action , what is the probability of reaching the end state ? This is particularly important in the context of a stochastic environment.
The reward function assigns quantitative score to a tuple of . As part of an MDP problem, we are ultimately interested in maximizing this score over a long-term period.
Given their definitions, these components are clearly crucial to any MDP framework! But guess what - in practice, we typically don’t know the true values for nor . Instead, we simulate agent interactions with the environment to sample from the distributions, in order to estimate their values. However, for the purposes of this lesson, assume we have known and so we can focus on solving MDPs.
Solving MDPs#
In order to solve an MDP, we must find the optimal policy mapping states to actions.
- Deterministic Policy:
- Stochastic Policy:
A good policy maximizes the discounted sum of future rewards:
- State Value Function : expected return of being in state following policy . Maps state to reward .
- State-Action Value Function : expected return of taking action from state following policy . Also known as the quality function. Maps state-action pair to reward .
Note that we can frame both the value function and optimal policy in terms of the quality function. More specifically…
- The optimal value of a state is equivalent to the maximum state-action value over all possible actions.
- The optimal policy at a given state should select the action which maximizes state-action value over all possible actions.
The Bellman Optimality Equation is a recursive decomposition of our reward maximization problem into the immediate reward and future expected reward.
Given this equation, we can now estimate the state value function and state-action value function as follows:
- Value Iteration: initialize values for all states . For each state, calculate . Repeat until converging to .
- Q-Value Iteration: similar approach to value iteration, but loop over potential actions in addition to states.
For each of these approaches, we first estimate the value / quality function, then calculate the optimal policy via one walkthrough of greedy policy extraction. An alternative approach is to estimate value using a given policy, then update the policy based on value estimates - this is known as Policy Iteration.
Value and Q-Value iteration are value-based approaches to solving MDPs. On the other hand, Policy Iteration is a policy-based method.
Example MDP: Grid World#
The most simple example of an RL system is Grid World which describes the following problem:
- Agent lives in a 2D grid environment.
- State: agent’s 2D coordinates.
- Actions: N, S, E, W.
- Rewards: +1/-1 at absorbing states.
- Stochastic State Transitions: 80% chance of proceeding in selected direction. 20% chance of proceeding perpendicular to selected direction (10% left, 10% right).

Deep Q-Learning#
Alright, so that’s all of reinforcement learning! Right? Not even close. One key issue with our current approach is the time complexity. Direct calculation of the state value function / state-action value function / policy has an unfavorable time complexity:
In a simple example such as Grid World, this isn’t too bad. However, for even moderately complicated environments involving larger state and action spaces, these approaches become too computationally expensive. So what’s the solution?
Deep Q-Learning is an approach to solving MDPs which learns a parameterized Q-function to estimate the state-action value function. Given a state : action pair as input, the Q-function outputs a score. In the simplest case, we can use a linear model to represent our Q-function:
In practice, we typically choose to fit a Deep Q-Network (DQN) to represent our Q-function. DQNs are simply neural networks which approximate the Q-function .
Training a DQN#
So how does the learning process work? Recall that the Bellman Equation defines the Q-function as follows:
Our objective function - Temporal Difference (TD) Error - minimizes the difference between our predicted and TD target Q values. Note the TD target is calculated by taking the actual reward received and adding it to the discounted state-action value for the next state .
There is one key issue with this representation - during parameter updates to , the network is also changing its estimate of the TD target, thus “moving the goalposts” for the loss calculation. To solve this problem, DQNs introduce the Target Network as a separate, frozen copy of the network which is used to calculate the TD target. We may then update this frozen network at fixed intervals.
Gathering Data#
Given our optimization approach, how should we go about collecting data via agent experience with the environment?
- We might start with a random data gathering policy to collect instances of .
- Use the data to train our DQN, then use the DQN to update our policy .
- Repeat this process until policy convergence.
While this approach is reasonable, it is problematic for one key reason - we are only exploring states which yield high reward relative to the current data-gathering policy. States with low reward as estimated by the current Q-function (but perhaps with high long-term reward) will be passed over. We must effectively balance Exploration vs. Exploitation by ensuring our algorithm strays from its path to explore alternative (lower-reward) paths:
- Exploration: select action that corresponds to uncertain rewards.
- Exploitation: select safe action that has good rewards according to the current Q-function.
Exploration vs. Exploitation efforts typically result in an Epsilon-Greedy approach to action selection. In practice, we use annealing to decay epsilon over time, which implies less weight is given to random action selection with increased experience.
Policy-Based Methods#
Whereas value-based methods estimate state value to optimize the policy, policy-based methods focus on directly optimizing the policy itself.

Similar to the case where we have a parameterized value function (as in DQN), we can also parameterize our policy.
Our objective function the expectation of discounted rewards over time.
Policy Gradients#
Given our objective, can we define the policy gradient to calculate during any update step of gradient descent? We define a similar setup to the case of supervised learning, but define our label as a sampled action.

(all images obtained from Georgia Tech DL course materials)