Lesson 62
Policy Gradient
Increase the probability of actions that led to higher return, and decrease the ones that led to less. One example is on this page.
Intermediate12 min
What You Will Learn
- Idea
- Example
- When to use it
Idea
A policy gradient method stores a policy, a probability for each action in a state. After a trajectory, actions that preceded a high return get a higher probability. Actions that preceded a low return get a lower one. There is no requirement to store a Q-table.
Example
rewards = [0, 0, 1]
ret = sum(rewards)
log_prob = -0.7
term = -log_prob * ret
print(f"return: {ret}")
print(f"update term: {term:.2f}")Output:
return: 1
update term: 0.70When to use it
- Use it when actions are naturally probabilities, or the best behavior is stochastic.
- A positive term on a sampled action pushes that action's probability up when the return is positive.
- Raw returns have high variance. A baseline or an advantage is the usual fix.
Loading playground…