Chapter 9 On-policy Prediction with Approximation
我们之前讲过,强化学习的主要目标是学习value function,即状态到动作的映射。之前的方法都是tabular methods,即用一个table/array来记录state对应的action或者value,但是这样就有一个缺点需要的内存非常大,因此我们考虑用有参数的函数来表示value function。
这个函数可能是一个线性函数,也可能是一个多层的神经网络,或者决策树。
1 Prediction
在前面的方法中,我们更新的方式是V=V+α(G−V)V=V+α(G−V),这个操作将V向目标G移动,因为根据experience我们知道,这个状态下的value应该更接近update target G。在机器学习中,这种模仿input-output的方法被称为监督学习方法,当output是数字时这个过程就叫做function approximation。这也是本章标题里approximation的由来。
由于我们可以把update当做是传统的training example,因此很多的监督学习方法都可以用,比如神经网络、决策树和多元回归方法。
但是有一个问题是,target function是在变的,因此强化学习方法需要处理这种非静态target function。
1.1 Prediction Objective(9.2节)
我们用一个参数向量ww来和state 共同控制value function,那么误差函数如下:
Prediction Objective(均方误差):
其中vπ(s)vπ(s)是真值;v^π(s,w)v^π(s,w)是估计;μ(s)μ(s)是state的分布,即各个state的和为1,我们经常把μ(s)μ(s)选为在状态s上花的时间。
我们希望这个函数值越小越好。
1.2 Stochastic/Semi gradient methods(9.3节)
1.2.1 SGD
对目标函数啊求偏导,沿该方向error下降的最快,这就是梯度下降:
由于真值vπ(St)vπ(St)我们是不知道的,所以用它的估计UtUt来代替它:
Gradient Monte Carlo:
1.2.2 Semi-gradient
如果我们使用真值vπ(St)vπ(St)的bootstrapping估计,那么就不是一个真正的梯度下降算法,因为bootstrapping估计依赖于当前的参数向量ww,这就意味着bootstrapping估计使biased的。、
如果我们忽略向量对target的作用,那么这就是semi-gradient方法。
虽然semi-gradient不向梯度下降方法那样有鲁棒性,但是在线性方法中是可以很好的converge的。而且,由于它有一些优点导致它被更多使用:
- 可以更快的学习,像TD methods那样,使用了bootstrapping估计
- enable learning to be continual and online, without waiting for the end of an episode. This enables them to be used on continuing problems and provides computational advantages
Semi-gradient TD(0):
2 Linear Methods
2.1 Linear methods(9.4节)
每一个状态state都对应一个向量x(s)=(x1(s),x2(s),...,xd(s))x(s)=(x1(s),x2(s),...,xd(s)),和参数向量ww的维度一样,也叫状态s下的特征向量,代表了s的特征。
那么线性方法通过两个向量的内积来估计state-value:
对其求偏导:
SGD update in the linear case:
The update at each time t:
Once the system has reached steady state, for any given wtwt, the expected next weight vector can be written
wTDwTD 是TD fixed point。
the natural extension of the tabular n-step TD algorithm:
其中:
2.2 feature construction(9.5节)
线性方法由于其收敛保证所有很受欢迎,但是它非常依赖于状态如何被特征表示。
但也有一个缺陷就是线性方法没有将特征间的关系考虑进去。
2.2.1 Polynomials
多项式特征很简单,当确定了基本的维度特征后,可以将几个特征进行组合,比如一开始只有两个维度的特征x(s)=(s1,s2)Tx(s)=(s1,s2)T,我们之后可以将特征组合,得到x(s)=(1,s1,s2,s1s2)x(s)=(1,s1,s2,s1s2)或者x(s)=(1,s1,s2,s1s2,s21,s22,s21s2,s1s22,s21s22)x(s)=(1,s1,s2,s1s2,s12,s22,s12s2,s1s22,s12s22)这样的特征。
但这样的特征组合太多,我们可以利用我们的先验知识来排除一些没必要的特征,比如3维物体的长宽高的四次方或更高基本是没有意义的。
2.2.2 Fourier Basis
这一节包括接下来的几节看不懂,先放放,回过头看。
2.2.3 Coarse Coding
2.2.4 Tile Coding
2.2.5 Radial Basis Functions
2.3 Selecting Step-Size Parameters Manually(9.6节)
传统的设置learning rate为αt=1tαt=1t,不适合TD方法、非静态问题和function approximation。
A good rule of thumb for setting the step-size parameter of linear SGD methods is:
3 Nonlinear Function Approximation(9.7节)
主要讲了神经网络,基础的知识就不讲了。
the architecture of a deep convolutional network:
其实主要就是卷积神经网络。
虽然现在大部分的强化学习理论都局限于tabular和线性function approximation方法,但很多强化学习应用的成功都归功于非线性的function approximation。
4 Least-Squares TD
之前我们讲过TD fixed point,我们为什么要迭代的计算这个点而不是直接计算这个点呢?
Least-Squares TD(LSTD)就是这么做的。它进行如下的估计:
其中ϵIϵI是为了At^At^可逆。
求At^At^和bt^bt^的时间和空间复杂度都是o(d2)o(d2),求逆的复杂度本来是o(d3)o(d3),但是它是外积的和,是个特殊的形式,所以可以被增量实现,只要o(d2)o(d2)的复杂度。
LSTD的好处是data efficiency,就是要的数据少了,但是复杂度上去了,所以是否要用lSTD要看自己的需求,d多大,是否需要快速学习。
LSTD:
5 Memory-based Function Approximation
Memory-based Function Approximation顾名思义,就是利用内存来进行function approximation,需要强调的是它不是基于参数的方法,它将每个example存入内存,直接利用这些内存里的example来进行估计,而不需要更新参数。
这里基于内存的function approximation和监督学习里的k近邻方法很像,k近邻是存入一些example,当预测一个example属于哪个类时,只要在已有的example里查找和它最近的k个example看这k个example属于哪个类比较多。
那么Memory-based Function Approximation就是将example变成state-value,查询时只要找与被查询的状态最接近的几个state就可以。
那么如何判断接近的程度呢?一种简单的判断就是直接看距离,距离的计算就看自己怎么定义距离了;稍微复杂一点的可以进行局部加权,和线性回归中的局部加权线性回归类似,书上也没有细讲吗,这里也不详细展开了。
6 Kernel-based Function Approximation
基于核的function approximation和上面的基于内存的方法中的一步比较像——度量两个state的距离。
kernel function就是这样一个函数:输入两个state,输出这两个state之间的相关度。前面讲feature construction时有一个方法叫tile coding,虽然没有直接用核函数,但其实它是对应了一个。
建立好核函数后,如何计算value function呢?其实就是把核函数当成权值,做加权平均就可以:
下面介绍两种常见的核函数:
the Gaussian radial basis function (RBF)
the inner product of the feature vector
7 Interest and Emphasis
- interest ItIt
a non-negative scalar measure, a random variable ItIt called interest, indicating the degree to which we are interested in accurately valuing the state (or state{action pair) at time t.
- emphasis MtMt
another non-negative scalar random variable, the emphasis MtMt. This scalar multiplies the learning update and thus emphasizes or de-emphasizes the learning done at time t.
n-step learning rule:
Interest and emphasis can result in more accurate value estimates.