本文主要是介绍Actor-critic学习笔记-李宏毅,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
- Policy Gradient review
∇ R ‾ θ = 1 N ∑ n = 1 N ∑ t = 1 T n ( ∑ t ′ = t T n γ t ′ − t r t ′ n − b ) ∇ log p θ ( a t n ∣ s t n ) \nabla \overline{R}_\theta = \frac{1}{N}\sum_{n = 1}^{N}\sum_{t = 1}^{T_n}(\sum_{t'=t}^{T_n}\gamma^{t'-t}r_{t'}^n-b)\nabla\log p_\theta(a_t^n|s_t^n) ∇Rθ=N1∑n=1N∑t=1Tn(∑t′=tTnγt′−trt′n−b)∇logpθ(atn∣stn)
问题是其中 G t n = ∑ t ′ = t T n γ t ′ − t r t ′ n G^n_t = \sum_{t'=t}^{T_n}\gamma^{t'-t}r_{t'}^n Gtn=∑t′=tTnγt′−trt′n不稳定,需要打样采样才可以得到期望值; - Q-Learning review
State value function: V π ( s ) V^\pi(s) Vπ(s)
State-action value function: Q π ( s , a ) Q^\pi(s,a) Qπ(s,a) - Action-Critic
- 如何直接获得 G t n = ∑ t ′ = t T n γ t ′ − t r t ′ n G^n_t = \sum_{t'=t}^{T_n}\gamma^{t'-t}r_{t'}^n Gtn=∑t′=tTnγt′−trt′n的期望值: E [ G t n ] = Q π θ ( s t n , a t n ) E[G^n_t] = Q^{\pi_\theta}(s_t^n,a^n_t) E[Gtn]=Qπθ(stn,atn),求期望值就是学习Q function,b一般取值为 V π θ ( s t n ) V^{\pi_\theta}(s_t^n) Vπθ(stn);
- 按照上面的方式计算的话要同时计算 Q , V Q,V Q,V,如何能值估一个Network,借助的式子是 Q π ( s t n , a t n ) = E [ r t n + V π ( s t + 1 n ) ] = r t n + V π ( s t + 1 n ) Q^\pi(s_t^n,a_t^n) = E[r_t^n+V^\pi(s_{t + 1}^n)]=r_t^n+V^\pi(s_{t + 1}^n) Qπ(stn,atn)=E[rtn+Vπ(st+1n)]=rtn+Vπ(st+1n),也就是在 s t s_t st的时候获得 r t n r_t^n rtn之后转到state s t + 1 s_{t + 1} st+1,这样上式从 Q π ( s t n , a t n ) − V π ( s t n ) → r t n + V π ( s t + 1 n ) − V π ( s t n ) Q^{\pi}(s_t^n,a^n_t)-V^\pi(s_t^n)\rightarrow r_t^n + V^\pi(s_{t + 1}^n)-V^\pi(s_t^n) Qπ(stn,atn)−Vπ(stn)→rtn+Vπ(st+1n)−Vπ(stn),现在就可以只用估计V function;
- 总结一下 ∇ R ‾ θ = 1 N ∑ n = 1 N ∑ t = 1 T n ( r t n + V π ( s t + 1 n ) − V π ( s t n ) ) ∇ log p θ ( a t n ∣ s t n ) \nabla \overline{R}_\theta = \frac{1}{N}\sum_{n = 1}^{N}\sum_{t = 1}^{T_n}(r_t^n + V^\pi(s_{t + 1}^n)-V^\pi(s_t^n))\nabla\log p_\theta(a_t^n|s_t^n) ∇Rθ=N1∑n=1N∑t=1Tn(rtn+Vπ(st+1n)−Vπ(stn))∇logpθ(atn∣stn),现在训练流程,首先有一个policy,然后和环境互动收集数据,然后首先estimate V function,之后有了 V π ( s ) V^\pi(s) Vπ(s),然后就可以更新actor,这样的流程不断重复;
- Tip1:policy的Network π ( s ) \pi(s) π(s)和critic的Network V π ( s ) V^\pi(s) Vπ(s)可以共享部分参数,因为都是输入state s s s;
- Tip2:也需要exploration,希望不同action的概率平均一点,以可以有概率尝试不同的action,更大的cross entropy;
- asynchronous actor critic(A3C)
- 开多个worker,每个worker复制一份参数,然后每个worker都和环境做互动,然后计算gradient;最后使用gradient来更新global的参数,每个worker是平行跑的;
这篇关于Actor-critic学习笔记-李宏毅的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!