强化学习的学习之路(十六)_2021-01-16:价值函数近似(Value function approximation)

作为一个新手,写这个强化学习-基础知识专栏是想和大家分享一下自己学习强化学习的学习历程,希望对大家能有所帮助。这个系列后面会不断更新,希望自己在2021年能保证平均每日一更的更新速度,主要是介绍强化学习的基础知识,后面也会更新强化学习的论文阅读专栏。本来是想每一篇多更新一点内容的,后面发现大家上CSDN主要是来提问的,就把很多拆分开来了(而且这样每天任务量也小一点哈哈哈哈偷懒大法)。但是我还是希望知识点能成系统,所以我在目录里面都好按章节系统地写的,而且在github上写成了书籍的形式,如果大家觉得有帮助,希望从头看的话欢迎关注我的github啊,谢谢大家!另外我还会分享深度学习-基础知识专栏以及深度学习-论文阅读专栏,很早以前就和小伙伴们花了很多精力写的,如果有对深度学习感兴趣的小伙伴也欢迎大家关注啊。大家一起互相学习啊!可能会有很多错漏,希望大家批评指正!不要高估一年的努力,也不要低估十年的积累,与君共勉!

Value function approximation
为什么需要做function approximation
  • Previous lectures on small RL problems:
    • Cliff walk: 4 × 16 4 \times 16 4×16 states
    • Mountain car: 1600 states
    • Tic-Tac-Toe: 1 0 3 10^{3} 103 states
  • Large-scale problems:
    • Backgammon: 1 0 20 10^{20} 1020 states
    • Chess: 1 0 47 10^{47} 1047 states
    • Game of Go: 1 0 170 10^{170} 10170 states
    • Q Robot Arm and Helicopter have continuous state space
    • (5 Number of atomics in universe: 1 0 80 10^{80} 1080

即使智能体具有完整和准确的环境模型,智能体也通常没有足够的计算能力在每一时刻都全面利用它。 而可用的存储资源也是一个重要的限制。精确的价值函数、策略和模型都需要占用储存资源。在大多数实际问题中,环境状态远远不是一个表格可以装下的。所以就想着用函数近似去解决这个问题,一来可以解决q表太大的问题,二来可以对于没有见过的状态有泛化性。

做function approximation的方式

当我们去对V函数做价值优化的时候,我们有两种情况

  • 一种是我们已经知道真值(这里的意思其实是知道部分真值,然后去对V函数做近似就可以有泛化能力):

We assumed that true value function v π ( s ) v^{\pi}(s) vπ(s) given by supervisor / oracle O Off-policy TD

  • 还有一种情况也是更现实的情况就是我们不知道V函数,我们只知道reward,那么我们就可以用前面的方法去估算V:

    • For M C \mathrm{M} \mathrm{C} MC, the target is the actual return G t G_{t} Gt

    Δ w = α ( G t − v ^ ( s t , w ) ) ∇ w v ^ ( s t , w ) \Delta \mathbf{w}=\alpha\left(G_{t}-\hat{v}\left(s_{t}, \mathbf{w}\right)\right) \nabla_{\mathbf{w}} \hat{v}\left(s_{t}, \mathbf{w}\right) Δw=α(Gtv^(st,w))wv^(st,w)

    R e t u r n G t \mathrm{Return} G_{t} ReturnGt is an unbiased, but noisy sample of true value v π ( s t ) v^{\pi}\left(s_{t}\right) vπ(st)

    • For T D ( 0 ) , T D(0), TD(0), the target is the T D T D TD target R t + 1 + γ v ^ ( s t + 1 , w ) R_{t+1}+\gamma \hat{v}\left(s_{t+1}, w\right) Rt+1+γv^(st+1,w)

    Δ w = α ( R t + 1 + γ v ^ ( s t + 1 , w ) − v ^ ( s t , w ) ) ∇ w v ^ ( s t , w ) \Delta \mathbf{w}=\alpha\left(R_{t+1}+\gamma \hat{v}\left(s_{t+1}, \mathbf{w}\right)-\hat{v}\left(s_{t}, \mathbf{w}\right)\right) \nabla_{\mathbf{w}} \hat{v}\left(s_{t}, \mathbf{w}\right) Δw=α(Rt+1+γv^(st+1,w)v^(st,w))wv^(st,w)

​ TD target R t + 1 + γ v ^ ( s t + 1 , w ) R_{t+1}+\gamma \hat{v}\left(s_{t+1}, \mathbf{w}\right) Rt+1+γv^(st+1,w) is a biased sample of true value v π ( s t ) v^{\pi}\left(s_{t}\right) vπ(st)

​ Why biased?

​ It is drawn from our previous estimate, rather than the true value: E [ R t + 1 + γ v ^ ( s t + 1 , w ) ] ≠ v π ( s t ) \mathbb{E}\left[R_{t+1}+\gamma \hat{v}\left(s_{t+1}, \mathbf{w}\right)\right] \neq v^{\pi}\left(s_{t}\right) E[Rt+1+γv^(st+1,w)]=vπ(st)

​ Using linear T D ( 0 ) , \mathrm{TD}(0), TD(0), the stochastic gradient descend update is
Δ w = α ( R + γ v ^ ( s ′ , w ) − v ^ ( s , w ) ) ∇ w v ^ ( s , w ) = α ( R + γ v ^ ( s ′ , w ) − v ^ ( s , w ) ) x ( s ) \begin{aligned} \Delta \mathbf{w} &=\alpha\left(R+\gamma \hat{v}\left(s^{\prime}, \mathbf{w}\right)-\hat{v}(s, \mathbf{w})\right) \nabla_{\mathbf{w}} \hat{v}(s, \mathbf{w}) \\ &=\alpha\left(R+\gamma \hat{v}\left(s^{\prime}, \mathbf{w}\right)-\hat{v}(s, \mathbf{w})\right) \mathbf{x}(s) \end{aligned} Δw=α(R+γv^(s,w)v^(s,w))wv^(s,w)=α(R+γv^(s,w)v^(s,w))x(s)
​ This is also called as semi-gradient, as we ignore the effect of changing the weight vector w on the target

  • Semi-gradient Sarsa for VFA Control:
    在这里插入图片描述

具体我们可以用一下几种模型去进行拟合:

  • Linear combinations of features 特征的线性组合

  • Neural networks 神经网络

  • Decision trees 决策树

  • Nearest neighbors

上面的选择其实是对label的选择,对于模型来说,我们可以表示为状态提取出的特征的线性变换:

Represent value function by a linear combination of features
v ^ ( s , w ) = x ( s ) T w = ∑ j = 1 n x j ( s ) w j \hat{v}(s, \mathbf{w})=\mathbf{x}(s)^{T} \mathbf{w}=\sum_{j=1}^{n} x_{j}(s) w_{j} v^(s,w)=x(s)Tw=j=1nxj(s)wj
The objective function is quadratic in parameter w \mathbf{w} w
J ( w ) = E π [ ( v π ( s ) − x ( s ) T w ) 2 ] J(\mathbf{w})=\mathbb{E}_{\pi}\left[\left(v^{\pi}(s)-\mathbf{x}(s)^{T} \mathbf{w}\right)^{2}\right] J(w)=Eπ[(vπ(s)x(s)Tw)2]
Thus the update rule is as simple as
Δ w = α ( v π ( s ) − v ^ ( s , w ) ) x ( s )  Update  =  Stepsize  ×  PredictionError  ×  Feature Value  \begin{array}{c} \Delta \mathbf{w}=\alpha\left(v^{\pi}(s)-\hat{v}(s, \mathbf{w})\right) \mathbf{x}(s) \\ \text { Update }=\text { Stepsize } \times \text { PredictionError } \times \text { Feature Value } \end{array} Δw=α(vπ(s)v^(s,w))x(s) Update = Stepsize × PredictionError × Feature Value 
Stochastic gradient descent converges to global optimum. Because in the linear case, there is only one optimum, thus local optimum is automatically converge to or near the global optimum.

强化学习的致命三要素
  • Function approximation

  • Bootstrapping

  • off-policy

    如果包含这三个要素,很有可能不稳定性就难以避免,如果只出现两个要素,那么不稳定性就是有可能避免的。

    在这三个要素中,FA是最不可能舍弃的,状态聚合或者非参数化的方法的复杂性随数据的增大而增大,都效果太差或价格太昂贵。

    不使用Boot strapping是有可能的,付出的代价是计算和数据上的效率。

    很多强化学习算法都是在解决这个不稳定性的问题

函数近似的收敛性

在这里插入图片描述

上一篇:强化学习的学习之路(十五)_2021-01-15: Sarsa和Q-learning及其Python实现

下一篇:强化学习的学习之路(十七)_2021-01-17:DQN(Deep Q Network:Human-level control through deep reinforcement learning)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值