Lesson 64
Actor-Critic
Let an actor choose actions and a critic score them, and train the actor on the critic's error instead of the raw return.
Intermediate12 min
What You Will Learn
- Idea
- Example
- When to use it
Idea
The actor is the policy. The critic estimates a value. After one step, the temporal-difference error is the reward plus the discounted next value, minus the current value. The actor moves toward actions with a positive error and away from actions with a negative error.
Example
reward, value, next_value, gamma = 1.0, 0.2, 0.0, 0.9
td_error = reward + gamma * next_value - value
print(f"td error: {td_error:.2f}")Output:
td error: 0.80When to use it
- Use it when episodes are long and waiting for the final return is too noisy.
- A positive TD error means the action did better than the critic expected.
- The critic has to be decent. A bad critic sends the actor the wrong way.
Loading playground…