# Reinforcement Learning

This paper provides an overview of the fundamentals of reinforcement learning (RL), a subfield of machine learning focused on goal-directed learning through interaction. The paper highlights the interdisciplinary nature of RL, with connections to psychology, neuroscience, economics, engineering, and mathematics.

### Key points from the paper

Agent-Environment Interaction:

RL problems involve an agent interacting with an environment.

The agent receives observations (o_t) and rewards (r_t) from the environment and takes actions (a_t).

The environment's response to the agent's action depends on its state (s_t), which updates at each time step.

The agent may construct its own notion of state (s^α_t) based on its history of observations, actions, and rewards.

Observability:

In fully observable environments, the agent's observation (o_t) is identical to the environment state (s_t).

In partially observable environments, the agent cannot observe the full environment state, and the next observation's distribution does not satisfy the Markov property.

Markov Processes and Markov Reward Processes:

A Markov process is a sequence of random states with the Markov property.

A Markov Reward Process (MRP) extends the Markov process by including a reward function and a discount factor (γ).

Markov Decision Processes (MDPs):

MDPs formalize single-agent RL problems and capture the key components available to the learning agent.

An MDP is described by a 5-tuple: states (S), actions (A), state transition probability kernel (P), immediate reward function (r), and discount factor (γ).

Policies, Value Functions, and Models:

A policy (π) is the agent's behavior function, denoting the probability of taking an action in a given state.

The value function (v_π(s)) predicts the expected discounted future reward from a state, given a policy.

The action-value function (q_π(s,a)) predicts the expected discounted future reward for executing an action in a state and subsequently following a policy.

Models estimate the state transition probability (P(s,a,s')) and the expected immediate reward (r(s,a)).

Bellman Equations and Optimality:

The Bellman expectation equation expresses the value function in terms of the expected immediate reward and the discounted value of the next state.

The optimal value function (v*(s)) and optimal action-value function (q*(s,a)) correspond to the maximum value achievable by any policy.

Optimal policies achieve the optimal value and action-value functions, and there is always a deterministic optimal policy for any MDP.

The Bellman optimality equation is non-linear and requires iterative solution methods.

This paper provides a solid foundation for understanding the key concepts and components of reinforcement learning. It highlights the importance of MDPs, policies, value functions, and optimality in the context of RL. Understanding these fundamentals is crucial for developing and applying RL algorithms to various problem domains.

### Dynamic Programming (DP)

Dynamic Programming (DP) is a class of algorithms used to compute optimal policies for a given Markov Decision Process (MDP) when a perfect model of the environment is available.

DP breaks down complex problems into subproblems and combines their solutions, which is particularly useful when subproblems overlap and their solutions are needed repeatedly.

In the context of MDPs, DP's recursive decomposition corresponds to the Bellman equation, and the cached solution corresponds to the value function. While DP assumes a fully known MDP and does not address the complete reinforcement learning problem, it is useful for planning.

Planning can be used to address the prediction problem by finding the value function vπ of a given policy π. This is done by iteratively applying the Bellman Expectation Backup (Equation 8) until convergence to a unique fixed point vπ. The convergence can be proven using the contraction mapping theorem (Banach fixed-point theorem).

The contraction mapping theorem states that when a Bellman expectation backup operator Tπ is applied to two value functions u and v, it is a γ-contraction. This means that the distance between Tπ(u) and Tπ(v) is always less than or equal to γ times the distance between u and v. This contraction property ensures that both u and v converge to the unique fixed point of Tπ, which is vπ.

For control problems, DP can be used to find the optimal value function v∗ and the optimal policy π∗. One approach is policy iteration, which consists of two steps:

Policy evaluation: The current policy π is evaluated to find its value function vπ.

Policy improvement: The policy is improved to π′ by selecting the action that maximizes the action-value function qπ(s,a) for each state s.

This process improves the value function such that vπ′(s) ≥ vπ(s) for all states s. Policy iteration is repeated until the Bellman optimality equation (14) is satisfied, indicating convergence to the optimal policy π∗.

A generalization of policy iteration is modified policy iteration, where instead of waiting for policy evaluation to converge, only n steps of evaluation are performed before policy improvement occurs. If n = 1, this is called value iteration, as the policy is no longer explicit and is determined directly by the value function. Like policy iteration, value iteration is guaranteed to converge to the optimal value function and policy, which can be proven using the contraction mapping theorem.

In summary, dynamic programming is a powerful tool for computing optimal policies in fully known MDPs. It leverages the recursive structure of the Bellman equation and the contraction properties of the Bellman backup operators to efficiently solve planning problems in reinforcement learning. Policy iteration and value iteration are two key DP algorithms that iteratively improve the policy and value function until convergence to the optimal solution is achieved.

### Policy Gradient Methods

The section of the paper you provided discusses policy gradient methods, which are a class of model-free reinforcement learning algorithms that directly optimize the policy parameters to maximize the expected return. The main ideas covered in this section are:

Policy Gradient Theorem

The policy gradient theorem provides a way to compute the gradient of the expected return with respect to the policy parameters. The theorem states that the gradient of the expected return is equal to the expectation of the product of the action-value function (q_π(s,a)) and the gradient of the log-policy (∇_θ log π(s,a)) under the state distribution induced by the policy (ρ_π(s)).

REINFORCE

REINFORCE is a Monte Carlo policy gradient algorithm that estimates the action-value function using the sample return (R_t). The policy parameters are updated using the gradient of the log-policy weighted by the return: θ ← θ + α R_t ∇_θ log π(s_t, a_t).

Actor-Critic Methods

Actor-critic methods use a separate function approximator (critic) to estimate the action-value function (q_w), while the policy (actor) is updated according to the policy gradient theorem. The critic is updated using temporal difference (TD) learning, such as SARSA: w ← w + α_1 (r_{t+1} + γ q_w(s_{t+1}, a_{t+1}) - q_w(s_t, a_t)) ∇_w q_w(s_t, a_t), and the actor is updated using the critic's estimate: θ ← θ + α_2 q_w(s_t, a_t) ∇_θ log π(s_t, a_t).

Baselines

To reduce the variance of policy gradient estimates, a state-dependent baseline (e.g., the value function v_π(s)) can be subtracted from the action-value function in the policy gradient update without introducing bias: ∇_θ J(θ) = E_π[(q_π(s,a) - v_π(s)) ∇_θ log π(s,a)].

Compatible Function Approximation

When using a function approximator for the critic (q_w), it can introduce bias in the policy gradient estimate. However, if the function approximator is compatible with the policy parameterization (i.e., ∇_w q_w(s,a) = ∇_θ log π(s,a)), the bias is eliminated, and the true policy gradient can be recovered.

Deterministic Policy Gradients (DPG)

DPG is an off-policy algorithm for deterministic policies (μ_θ : S → A) in continuous action spaces. The policy parameters are updated using the deterministic policy gradient theorem: ∇_θ J(θ) = E_{s~ρ_μ}[∇_θ μ_θ(s) ∇_a q_μ(s,a)|_{a=μ_θ(s)}], where the critic (q_w) is learned using Q-learning, and the policy is updated using the gradient of the critic with respect to the actions.

In summary, this section presents various policy gradient methods that directly optimize the policy parameters to maximize the expected return, using either Monte Carlo estimates (REINFORCE) or actor-critic methods with function approximation. The policy gradient theorem, baselines, compatible function approximation, and deterministic policy gradients are key concepts introduced in this section.

### Reinforcement Learning Approaches

This section of the paper discusses model-based reinforcement learning approaches, which involve learning a model of the environment to make predictions and plan actions. The main ideas covered in this section are:

Model Learning: In model-based RL, the agent learns to approximate the state transition function (P_η ≈ P) and the immediate reward function (r_η ≈ r) of the environment. These approximations can be learned using supervised learning methods, such as regression for scalar rewards and density estimation for predicting the distribution over next states. Various function approximators, including neural networks and Gaussian processes, can be used for model learning.

Combining Model-Free and Model-Based Approaches: Once a model is learned, it can be used for planning. However, full-width backups using dynamic programming may be computationally infeasible for large state spaces. Instead, experiences can be sampled from the learned model and used as data for model-free algorithms. The Dyna architecture is a well-known example that combines model-based and model-free RL by treating simulated and real experiences similarly to learn a value function.

Forward Search: In some cases, such as deciding on the next move in chess, it is useful to start all rollouts from the current state when choosing the next action. This is known as forward search, where a search tree is built with the current state as the root. Forward-based search often uses sample-based rollouts (simulation-based search) to remain computationally tractable.

Monte-Carlo Tree Search (MCTS): MCTS is an effective algorithm for simulation-based search. It uses Monte Carlo returns to estimate the action-value function for all nodes in the search tree using the current policy. The policy is then improved, for example, by being ε-greedy with respect to the new action-value function or by handling exploration-exploitation using Upper Confidence Trees. MCTS is equivalent to Monte Carlo control applied to simulated experience and is guaranteed to converge on the optimal search tree.

TD-Based Control for Search: Instead of using Monte Carlo control for search, it is also possible to use TD-based control, which can increase bias but reduce variance.

Recent Advances: The paper mentions two recent advances in model-based RL: MuZero, which extends model-based predictions to value functions and policies, and Dreamer, which plans using latent variable models.

In summary, this section highlights the importance of model-based RL approaches, where the agent learns a model of the environment to make predictions and plan actions. The authors discuss various techniques for combining model-based and model-free methods, such as the Dyna architecture, and emphasize the importance of forward search and simulation-based search algorithms like Monte-Carlo Tree Search. The section also mentions recent advances in model-based RL, showcasing the active research in this area.

### Latent Variable Models

This section of the paper discusses latent variable models and partially observable Markov decision processes (POMDPs) in the context of reinforcement learning. The main ideas covered in this section are:

Latent Variable Models

Latent variables are variables that are not directly observed but influence the observed variables and can be inferred from observations. In reinforcement learning, inferring latent variables can provide a simpler and more parsimonious description of the world, enabling better predictions of future states and more effective control. The paper describes the probability distribution over observed variables x using latent variables z, parameterized by θ_x|z and θ_z. Key aims in unsupervised learning with latent variable models include capturing high-dimensional correlations, generating samples from a data distribution, describing underlying generative processes, and flexibly modeling complex distributions.

Partially Observable Markov Decision Processes (POMDPs)

POMDPs are a generalization of MDPs in which the agent cannot directly observe the true state of the system, and the dynamics are determined by an underlying MDP. A POMDP is defined by a 7-tuple (S, A, P, r, O, Ω, γ), where S is the set of states, A is the set of actions, P is the state transition probability kernel, r is the reward function, O is the set of observations, Ω is the observation probability kernel, and γ is the discount factor. In POMDPs, agents seek to learn a policy π(s^α_t) that maximizes the expected cumulative reward, where s^α_t is the agent's representation of the state, which is a function of its history.

Belief States

One approach to solving POMDPs is by maintaining a belief state over the latent environment state, where the transitions satisfy the Markov property. Belief states can be updated using the previous belief state, the action taken, and the current observation, as shown in Equation 49. Maintaining a belief state allows a POMDP to be formulated as an MDP, where every belief is a state. However, maintaining belief states in POMDPs is computationally intractable for most reasonably sized problems.

Approximate Solutions and Function Approximators

To address the computational intractability of maintaining belief states in POMDPs, approximate solutions can be used. Alternatively, agents learning using function approximators that condition on the past can construct their own state representations, which may enable relevant aspects of the state to be approximately Markov.

In summary, this section introduces the concept of latent variable models and their application in reinforcement learning to infer hidden variables that influence observed variables, providing a simpler and more parsimonious description of the world. The authors also discuss partially observable Markov decision processes (POMDPs), which generalize MDPs to situations where the agent cannot directly observe the true state of the system. The section highlights the challenges of solving POMDPs, such as the computational intractability of maintaining belief states, and suggests approximate solutions and the use of function approximators to address these challenges.

### Deep Reinforcement Learning (DRL)

Deep Reinforcement Learning (DRL) is a subfield of reinforcement learning that combines RL techniques with deep learning, using artificial neural networks as function approximators for policies and value functions. DRL has gained significant attention since its successful application in learning to play Atari games from raw pixel input (Mnih et al., 2013). The main ideas covered in this section are:

Convolutional Neural Networks (CNNs): CNNs are particularly effective at extracting useful features from images and have been extensively used in supervised image classification tasks. In the context of DRL, CNNs are used to learn from high-dimensional pixel inputs, enabling agents to learn directly from raw visual data.

Stabilizing Training in DRL: Training deep neural networks in RL settings can be challenging due to issues such as correlated samples and unstable targets. The paper highlights two key techniques used to overcome these challenges: experience replay and target networks.

Experience Replay: Instead of using experiences immediately for learning, they can be stored in a replay buffer and sampled at a later point in time. This technique, introduced by Mnih et al. (2013) for their "deep Q-learning" algorithm, breaks the correlation between samples, reducing the variance of updates and the potential to overfit to recent experiences. Experiences can be sampled randomly or prioritized based on their importance, determined using the temporal-difference error (Schaul et al., 2015).

Target Networks: When using temporal difference learning with deep function approximators, a common challenge is the stability of learning. This instability arises when the same function approximator is used to evaluate both the current state's value and the target state's value for the temporal difference update. To address this issue, DRL algorithms often use a separate target network that remains stable while the standard network is updated. The target network's parameters are periodically copied from the standard network or updated using Polyak averaging (Equation 50) to prevent the target network from diverging too far from the standard network's improved predictions.

In summary, this section introduces the concept of deep reinforcement learning (DRL), which combines RL techniques with deep learning to enable agents to learn from high-dimensional inputs, such as raw pixel data. The authors highlight the success of convolutional neural networks (CNNs) in learning useful features from images and discuss two key techniques used to stabilize training in DRL: experience replay and target networks. Experience replay breaks the correlation between samples and reduces the variance of updates, while target networks maintain a stable target for temporal difference learning, preventing instability caused by using the same function approximator for both current and target state value estimates.

Last updated