Chapter 9: On-policy Prediction with Approximation
From this chapter, we move from tabular methods to approximate methods to tackle the curse of dimension in the state space. Instead of storing a lookup table for state values in tabular methods, approximate methods learn state values with function approximation, i.e., .
However, approximate methods are not simple combination of RL and supervised learning. Compared to tabular RL methods, approximate methods introduce the challenge of generalization, i.e., the change of based on one state will also change the value of all other states, while the values of different states are decoupled in tabular case. In other words, with function approximation, we have lost the policy improvement theorem under the tabular case. Compared to standard supervised learning on a static distribution, function approximation in RL raises new issues such as nonstationarity (the training samples are collected online from a time-variant policy), bootstrapping (the learning target itself is dependent on the parameters), and delayed targets.
This chapter starts from the simplest case, i.e., on-policy prediction (value estimation) with approximation given a fixed policy.
The Prediction Objective
The prediction problem can be seen as a supervised learning problem, where the data distribution is the on-policy distribution generated by the policy . The on-policy distribution is the normalized fraction of time spent in .
Under the on-policy distribution, the learning objective is defined as However, we need to note that
Remember that our ultimate purpose--the reason we are learning a value function--is to find a better policy. The best value function for this purpose is not necessarily the best for minimizing . Nevertheless, it is not yet clear what a more useful alternative goal for value prediction might be.
Stochastic-gradient and Semi-gradient Methods
If we know the true state values, then we can learn with standard SGD as follows: However, the challenge in RL is that we don't have a ground-true as in supervised learning. Instead, we need to use a backup estimation as the target.
If is an unbiased estimate, like in MC (), then is guaranteed to converge to a local minimum under the usual stochastic approximation conditions for decreasing .
However, for TD, our alternative target is not independent of . Consequently, we can not apply standard SGD, but use semi-gradient methods for update, i.e., only take into account the gradient of w.r.t. the current estimate, while ignore its gradient w.r.t. the target part. Altough semi-gradient methods converge less robustly, they do converge reliably in the linear case, and more importantly, they typically enable significantly faster and fully continual and online learning.
Linear Methods and Least-Squares TD
When the approximation function is linear, we can write the semi-gradient update explicitly as:
In expectation, we have where , and . Thus the converged solution, i.e., the TD fixed point, satisfies . Consequently, instead of using iterative algorithm like SGD, we can directly compute the closed-form solution for linear methods. This is known as the least-squared TD algorithm, and its complexity is , where is the state space dimension. Matrix inverse typically requires a complexity of . However, the matrix is the sum of vector outer product, thus its inverse can be computed more efficiently using the Sherman-Morrison formula.