On-policy Control with Function Approximation
In the previous page, we explored on-policy prediction with function approximation, focusing on how to estimate value functions using Monte Carlo and TD methods. This page extends those ideas to the control problem, where the goal is to optimize the policy while estimating action-value functions .
Episodic Semi-Gradient Sarsa
To adapt function approximation to the control setting, we need to extend value function updates to action-value functions . The update rule becomes:
where the TD Error is:
This method, called episodic semi-gradient Sarsa, combines the following components:
- Action-Dependent Features: Feature vectors now include both states and actions.
- Policy Improvement: Policies are improved incrementally using -greedy or other soft action-selection strategies.
Input: A differentiable action-value function parameterization
Algorithm parameters: Step size , small
Initialize: Value-function weights arbitrarily (e.g., )
Loop for each episode:
initial state and action of the episode (e.g., -greedy)
Loop for each step of episode:
Take action , observe
If is terminal:
Go to next episode
Choose as a function of (e.g., -greedy)
Semi-Gradient n-step Sarsa
The episodic Sarsa update can be extended to use n-step returns for bootstrapping, allowing the agent to balance short-term and long-term rewards:
n-step methods improve stability and convergence in episodic tasks by integrating rewards across multiple steps, reducing variance compared to one-step updates.
Input: A differentiable action-value function parameterization
Input: A policy (if estimating )
Algorithm parameters: Step size , small , a positive integer
Initialize: Value-function weights arbitrarily (e.g., )
All store and access operations () can take their index mod
Loop for each episode:
Initialize and store terminal
Select and store an action or -greedy wrt
Loop for :
If , then:
Take action
Observe and store the next reward as and the next state as
If is terminal, then:
Else:
Select and store or -greedy wrt
(time whose estimate is being updated)
If :
If , then
Until
Average Reward
In continuing tasks (no terminal states), discounted rewards are often problematic with function approximation. Instead, the average reward objective provides an alternative formulation:
Average Reward Definition
Unlike discounted return formulations, the average reward treats immediate and delayed rewards equally. The policy's performance in the average reward setting is defined as the average reward per time step, calculated as: