强化学习2--策略梯度(2)

\pi:s\rightarrow a

从s到最后一个状态的一个系列 T:s_t,s_{t+1},\dots,s_T

奖励R(T)是一个随机变量

目标函数:随机变量的期望J=\int R(T)P_\pi(T)dT(1)

\pi^\ast:s\rightarrow u^\ast:对于系列s_t,s_{t+1},\dots,s_T,找到最优策略u_{​{}^0}^\ast\rightarrow u_1^\ast\rightarrow u_{​{}^2}^\ast\rightarrow\dots\rightarrow u_T^\ast

假设神经网络的结构参数为\theta

公式(1)化简可得:J(\theta)=E_{T\sim\pi\theta(T)}\lbrack r(T)\rbrack=\int_{T\sim\pi\theta(T)}\pi_\theta(T)r(T)dT(2)

公式(2)求取梯度得:\nabla_\theta J(\theta)=\int_{T\sim\pi\theta(T)}\nabla_\theta\pi_\theta(T)r(T)dT(3)

通过倒数求变换得:\nabla_\theta\pi_\theta(T)=\pi_\theta(T)\nabla_\theta\log\pi_\theta(T)(4)

(4)代入(3)得到:\nabla_\theta J(\theta)=\int_{T\sim\pi\theta(T)}\pi_\theta(T)\nabla_\theta\log\pi_\theta(T)r(T)dT(5)

对于序列T,策略\pi(T)=\pi(s_0,a_0,s_1,a_1,\dots,s_T,a_T)

\pi(T)=p(s_0)\prod_{t=0}^T\pi_\theta(a_t\vert s_t)p(s_{t+1}\vert s_t,a_t)(6)

将6代入5得:

\begin{array}{l}\nabla_\theta\log\pi_\theta(T)=\nabla_\theta\log(p(s_0)\prod_{t=0}^T\pi_\theta(a_t\vert s_t)p(s_{t+1}\vert s_t,a_t))\\=\nabla_\theta(\log p(s_0)+{\textstyle\sum_{t=0}^T}\log\pi_\theta(a_t\vert s_t)+{\textstyle\sum_{t=0}^T}{\textstyle\log}p(s_{t+1}\vert s_t,a_t))\\={\textstyle\sum_{t=0}^T}\nabla_\theta{\textstyle\log}{\textstyle{\scriptstyle\pi}_\theta}{\textstyle(}{\textstyle{\scriptstyle a}_t}{\textstyle\vert}{\textstyle{\scriptstyle s}_t}{\textstyle)}\end{array}(7)

策略梯度:\begin{array}{l}\nabla_\theta J(\theta)=E_{T\sim\pi\theta(T)}\lbrack\nabla_\theta l\mathrm{og}\pi_\theta(T)r(T)\rbrack\\=\frac1N{\textstyle\sum_{t=0}^N}\lbrack{\textstyle\sum_{t=0}^T}{\textstyle{\scriptstyle\nabla}_\theta}{\textstyle\log}{\textstyle\pi_\theta}{\textstyle(}{\textstyle a_t}{\textstyle\vert}{\textstyle s_t}{\textstyle)(\sum_{t=0}^Tr(s_t\vert a_t))\rbrack}\end{array}

更新梯度\widehat\theta=\theta+\alpha\nabla_\theta J(\theta)

 

优点

  • 更好的收敛性
  • 高效处理行为空间维度较高或者是连续的问题
  • 能够学到一些随机策略
  • 计算价值函数很困难,基于策略函数就简单了

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值