Policy Gradient Methods
In this chapter, you'll learn about:
- Policy Gradient Methods: Techniques for learning policies directly by optimizing parameterized functions.
- The Objective for Learning Policies: Defining objectives for policy optimization.
- The Policy Gradient Theorem: A key result for computing policy gradients.
- Actor-Critic Methods: Combining policy gradients with value function approximation.
- Policy Parameterizations: Implementations using softmax policies for discrete actions and Gaussian policies for continuous actions.
In previous chapters, we've focused on methods that learn value functions to derive optimal policies. Algorithms like Q-Learning and Sarsa estimate action values and then use these estimates to make decisions. In this chapter, we'll explore a different approach: Policy Gradient Methods, which directly parameterize and optimize the policy without the need to estimate value functions for action selection.
Introduction to Policy Gradient Methods
In policy gradient methods, we aim to learn a policy that maps states directly to actions without relying on value functions. Instead of deriving the policy indirectly from estimated value functions, we parameterize the policy itself and adjust its parameters to maximize some objective function, typically the expected return.
For example, consider the Mountain Car problem, where an underpowered car must drive up a steep hill. Previously, we used value-based methods with ε-greedy policies derived from estimated action values. However, we can also define a policy that directly maps the car's state (position and velocity) to an action (accelerate left, accelerate right, or do nothing) and adjust the policy parameters to maximize performance.
Parameterizing Policies
We represent the policy using a parameterized function with parameters . The policy outputs the probability of taking action in state . Our goal is to find the parameters that maximize the expected return.
To ensure that is a valid probability distribution over actions in each state, it must satisfy:
- for all
One common way to parameterize policies is using the softmax function over action preferences.
Softmax Policy
The softmax policy assigns probabilities to actions based on their preferences :
- The preferences can be any real-valued function parameterized by .
- The exponential function ensures that all probabilities are positive.
- The denominator normalizes the probabilities so they sum to one.
Gaussian Policy
For continuous action spaces, we can parameterize the policy as a Gaussian distribution.
The policy outputs mean and standard deviation :
- and can be parameterized using function approximators (e.g., linear functions, neural networks).
Policy gradient methods offer several advantages over value-based methods:
- Continuous Actions: They naturally handle continuous action spaces by parameterizing the policy over continuous variables.
- Stochastic Policies: They can represent stochastic policies, which may be optimal in certain settings where deterministic policies cannot achieve the best performance due to function approximation limitations.
- Autonomous Exploration: The agent can adjust its policy to reduce exploration over time, converging to a deterministic policy if appropriate.
- Simpler Policies: In some problems, the optimal policy may be simpler than the optimal value function, making direct policy learning more efficient.
The Objective for Learning Policies
To learn a parameterized policy , we need to define an objective function that quantifies the performance of the policy. A common objective is the expected return.
Expected Return Objective
For continuing tasks, we can define the average reward per time step under policy :
- is the stationary distribution over states induced by policy .
- is the transition probability from state to given action .
- is the expected reward when transitioning from to using action .
Our goal is to find that maximizes :
Policy Gradient Approach
We can use gradient ascent to find :
- is the learning rate.
- is the gradient of the expected return with respect to the policy parameters.
However, computing directly is challenging due to the dependence of on .
The Policy Gradient Theorem
The Policy Gradient Theorem provides a way to compute the gradient without needing to differentiate .
For any differentiable policy , the gradient of the expected return is:
- is the action-value function under policy .
- In the episodic case, the gradient is proportional (denoted by the symbol ) to the average length of the episode. In the continuing case, the relationship is an equality.
Moreover, using the identity , we can write:
- This expression allows us to estimate the gradient using samples collected while following policy .
- The dependence of on cancels out, simplifying the computation.
- The gradient consists of an expectation over states and actions encountered under the policy.
Estimating the Policy Gradient
Since and