RL 010
Policy Search Methods
Instead of and functions, we directly estimate the optimal policy.
- Policy was generated directly from the value function (e.g. -greedy)
- Parameterize the policy directly.
- Instead of or , we have
- Given a particular state , what actions should we take? (What is probability of that particular action?)
- is a learnable parameter which could be a neural network.
Value-based and Policy-based Methods
- Value-based: Learnt value function, Implicit policy (e.g. -greedy)
- Policy-based: No value function, Learnt policy.
- Good convergence properties
- Effective in high-dimensional or continuous action spaces
- if it is really continuous and large, it is not efficient as well.
- Can learn stochastic policies.
- Sometimes policies are relatively simple, values and models are complex.
- Typically reaches local optima.
- Obtained knowledge is specific and does not generalize well.
- Actor-Critic: Learnt value function, Learnt policy.
Policy Gradient Techniques
- Trust-Region Based: Optimize the policy in a trust zone (closer circle).
Stochastic policies
Rock-Paper-Scissors
- A deterministic policy is easily exploited
- Deterministic policy: If we follow a set of action or sequence of actions, we will definitely reach the goal and will always reach teh same location.
- A uniform random policy is optimal policy.
Grid World

- Agent cannot differentiate between the grey states.
- features describing state and action .
- is the North and the South are walls and the agent will move to the East.
- If , then when the agent is in the left grey state, it will move west, get stuck in a loop, and never reach the goal.

- Therefore, an optimal stochastic policy moves randomly or in grey states.
- The agent will reach the goal with high probability.
- Policy-based methods can learn Stochastic policies. 4563
Objective Function in Policy-based Methods
Given a policy with parameters , the goal is to find the best .
- In an episodic task (with an end state), is for that particular start state and measures how much expected return we can get.
- is the start state.
- is the measure of the quality of the policy or the objective function to optimize.
- In continuing environments (doesn't have an end state), consider the states and take the average value weighted by how often the agent visits each state.
- is how often the agent is visiting that particular state .
- Use the average reward per time step.
- Small batches can be used to estimate this average reward during training.
Policy-based Methods
- Policy-based RL is an optimization problem, find that maximize .
- is the policy objective function.
- Gradient-free methods: Hill Climbing, Genetic Algorithms, ...
- Gradient-based
- Policy gradient method will search for a local minimum in by ascending the gradient of the Policy.
- why ascending? because we want to maximize the objective function's value/rewards.
- is the step size.
- Assume the policy is differentiable.
- Compute an estimate of the policy gradient.
- Compute using Monte Carlo samples since we need to explore the environment, gather information, and then learn the policy.
Score Function
- Assume the policy is differentiable.
- is the gradient.
- Multiplying and dividing by is called the Likelihood Ratio Trick.
- Since , this does not change the original value.
- is Gradient of the policy
- is the policy.
- measures how sensitive the policy is to changes in , relative to the policy value itself.
- From the derivative rule of the logarithm, .
- Since , this does not change the original value.
- Score Function: .
Policy Gradient Theorem
Policy Gradient = How policy changes How good the action is.
- It generalizes the likelihood ratio approach to multi-step MDPs.
- Replaces the instantaneous reward with the action value function .
- The theorem applies to start state objective, average reward, and average value objectives.
- : the expected long-term reward starting from state , taking action and following policy
- : How sensitive the policy is to changes in .
- : Average over all possible states and actions according to the policy .
- : The direction in which should be changed to increase the objective .
Simplified Policy Gradient steps
- Loop
- Collect trajectories for Policy
- Estimate advantage function
- Compute Policy Gradient
- Update Policy Parameter
- is the estimated policy gradient.
- Can be MC policy gradient, or Actor-Critic Policy Gradient.
- if is too big, data collected under bad policy and it cannot be recovered.
- if is too small, it is not efficient use of experience.
REINFORCE Algorithm
- Monte Carlo Policy Gradient: explore and learn from the environment and learn the optimal policy.
- Update Parameters by Stochastic Gradient Ascent.
- Using policy gradient theorem: find the partial derivatives to find the direction of the gradient.
- Using return as an unbiased sample of .
REINFORCE: Sutton and Barto
- Slow to converge.
- Going to have low bias but high variance.
Actor-Critic
- Actor has a supervisor (Critic) that tells it how good or bad the action actor took is.
- Actor: Controls agent's behavior using Policy-based methods.
- Critic: Measures how good the action taken by the agent is using Value-based methods.
Reducing Variance using a Critic
- Monte Carlo policy gradient has high variance.
- Use a Critic to estimate the action-value function.
- Actor-Critic algorithms maintains two sets of parameters:
- Critic: Updates action-value function parameters .
- It is solving the problem of policy evaluation.
- How good is the policy for current parameters ?
- MC or TD methods to estimate the value function.
- Actor: Updates policy parameters in the direction advised by the Critic.
- It follows an approximate policy gradient.
Action-Value Actor-Critic
- Using Linear value function approximation:
- Critic: Use Linear TD(0) to update .
- Actor: Use policy gradient to update .
- is Critic.
- is Actor.
- Update : Critic can provide a better advice.
Actor-Critic: Sutton and Barto
TRPO, Trust Region Policy Optimization
- Advantage: the difference between the Q and the V values.
- How good is an action compared to the average action for a specific state.
- = the expected long-term return when taking action in state
- = the expected average long-term return when following the policy from state
- Used in many Deep RL algorithms such as TRPO, PPO, GRP and etc.
- Stationary Target: Fixed target during training.
Update the old policy to a new policy such that they are with in a "Trusted" distance apart.
- Conservative policy update allows improvement instead of degradation of policy.
- Improve training stability by avoiding parameter updates that changes the policy too much at one step.
- By enforcing KL divergence constraint on size of the policy update at each iteration.
Kullback-Leibler Divergence
KL divergence score
- It quantifies how much one probability distribution differs from another probability distribution.
- indicates divergence or 's divergence from .
- Given two probability distributions and over a discrete random variable , the KL divergence is the expected value under of the log ratio between and .
- Multiplying by gives more weight to events that occur frequently under .
- large, small → large divergence
- small, large → effect is smaller
- e.g. and , while and
- The policy changed drastically in one update step.
- TRPO prevents this by enforcing .
TRPO vs Gradient Descent
| Comparison | Gradient Descent | Trust Region |
|---|---|---|
| Optimization approach | Picks the steepest direction. | Defines a region in which to search for the next point. |
| Step | Moves forward by a step size. | Determines the maximum step size to explore. |
| Next point | Moves directly in the selected direction. | Locates the optimal point within the trust region. |
| Search process | Repeats the directional step. | Resumes the search from the selected point. |
| Main characteristic | Fast and simple for optimizing an objective function. | Controls how far the optimization explores at each step. |
| In Reinforcement Learning | May not work well in reinforcement learning. | Provides a restricted region for finding the next optimal point. |

PPO, Proximal Policy Optimization
- TRPO is relatively complicated, every time we need to find trust region and solve the optimization problem, leading to high computational cost.
- PPO simplifies it by using a Clipped Surrogate function
- Based on a ratio of two policies
- Current Policy
- Baseline Policy (Old Policy)
Policy Ratio
- : no policy change
- : the action becomes more likely
- : the action becomes less likely
The surrogate objective is:
- : the action was better than expected → increase its probability.
- : the action was worse than expected → decrease its probability.
- Without a restriction, the policy may change too much in a single update.
Clipped Surrogate Objective
- is the ratio of the new policy to the old policy.
- is the advantage function.
- is a hyperparameter, usually or .
- If , the clipping range is .
- For , PPO removes the benefit of increasing above .
- For , PPO removes the benefit of decreasing below .
- The policy ratio itself is not strictly forced to remain inside the clipping range.
- Instead, clipping removes the incentive for excessively large beneficial policy updates.

- : Initial policy parameters.
- : Clipping threshold.
- : , where , for .




























