Applied AI Vol. 2 · 4 min read
In many reinforcement learning tasks, the agent gets feedback only at the end. Hand-designed intermediate rewards can speed learning, or quietly teach the wrong behavior.
The risk of naive shaping
If you reward an agent for something you think correlates with success, such as moving toward a goal, it may learn to exploit that reward instead of reaching the goal. An agent rewarded for proximity can circle near the goal forever.
Potential-based shaping
Define a potential function Φ over states, a guess at how promising each state is. Add to the reward for a transition from state s to s′ the quantity γΦ(s′) − Φ(s), where γ is the discount factor.
A classical result shows that this kind of shaping does not change which policies are optimal. The added terms telescope along a trajectory, so they change the value of each state by a function of the state alone, and not the ranking of actions.
Using it well
- A good potential, such as an estimate of remaining distance or a learned value, can greatly speed up learning.
- A bad potential does not break optimality, but it can slow learning.
- Check the learned behavior on the original, unshaped reward, since that is the one you care about.
- Reward terms that are not of this form can change the optimum, so treat them as part of the objective and test accordingly.
