当前位置: 首页 > wzjs >正文

商业网站首页怎么做百度有哪些app产品

商业网站首页怎么做,百度有哪些app产品,网站优化建设公司,中山做网站优化引言 强化学习中贝尔曼方程的重要性就不说了,本文利用高中生都能看懂的数学知识推导贝尔曼方程。 回报 折扣回报 G t G_t Gt​的定义为: G t R t 1 γ R t 2 γ 2 R t 3 ⋯ ∑ k 0 ∞ γ k R t k 1 (1) G_t R_{t1} \gamma R_{t2} \gamm…

引言

强化学习中贝尔曼方程的重要性就不说了,本文利用高中生都能看懂的数学知识推导贝尔曼方程。

回报

折扣回报 G t G_t Gt的定义为:
G t = R t + 1 + γ R t + 2 + γ 2 R t + 3 + ⋯ = ∑ k = 0 ∞ γ k R t + k + 1 (1) G_t = R_{t+1} +\gamma R_{t+2} + \gamma^2 R_{t+3} + \cdots = \sum_{k=0}^\infty \gamma^k R_{t+k+1} \tag 1 Gt=Rt+1+γRt+2+γ2Rt+3+=k=0γkRt+k+1(1)
注意 G t G_t Gt描述的是一条轨迹上的结果,也就是从某个时刻 t t t开始,在这条轨迹上,未来累积获得的奖励。

价值函数

状态价值函数表示从某个状态 s s s开始,智能体能获得的期望回报。
V π ( s ) = E [ G t ∣ S t = s ] (2) V^\pi(s) = \Bbb E[G_t|S_t=s] \tag 2 Vπ(s)=E[GtSt=s](2)
意思是

  • 从状态 s s s出发
  • 遵循策略 π \pi π行动
  • 未来累计获得的回报 G t G_t Gt的期望值

描述的是很多条轨迹的回报的平均值。

状态价值函数是针对所有状态的,强化学习的环境可能有成千上万个状态,我们一开始并不知道每个状态的价值。

所以,需要一种方法来求出 V π ( s ) V^\pi(s) Vπ(s)

这种方法就是贝尔曼方程。

贝尔曼方程

状态价值函数

价值函数通常通过贝尔曼方程来递归定义,它为价值函数提供了一种递推的方式。

我们来一步一步推导理解它。

回顾一下状态价值函数的定义:
V π ( s ) = E [ G t ∣ S t = s ] V^\pi(s) = \Bbb E[G_t|S_t=s] Vπ(s)=E[GtSt=s]
其中 G t G_t Gt可以展开为:
G t = R t + 1 + γ R t + 2 + γ 2 R t + 3 + ⋯ = R t + 1 + γ G t + 1 (3) G_t =R_{t+1} +\gamma R_{t+2} + \gamma^2 R_{t+3} + \cdots = R_{t+1} + \gamma G_{t+1} \tag 3 Gt=Rt+1+γRt+2+γ2Rt+3+=Rt+1+γGt+1(3)
其中 G t + 1 G_{t+1} Gt+1是依赖于 t + 1 t+1 t+1时刻的状态 S t + 1 S_{t+1} St+1的未来回报。

我们得到:
V π ( s ) = E [ R t + 1 + γ G t + 1 ∣ S t = s ] (4) V^\pi(s) = \Bbb E[R_{t+1} + \gamma G_{t+1}|S_t=s] \tag 4 Vπ(s)=E[Rt+1+γGt+1St=s](4)
利用期望的可加性我们继续展开:
E [ R t + 1 + γ G t + 1 ∣ S t = s ] = E [ R t + 1 ∣ S t = s ] + E [ γ G t + 1 ∣ S t = s ] (5) \Bbb E[R_{t+1} + \gamma G_{t+1}|S_t=s] = \Bbb E[R_{t+1} |S_t=s] + \Bbb E[ \gamma G_{t+1}|S_t=s] \tag 5 E[Rt+1+γGt+1St=s]=E[Rt+1St=s]+E[γGt+1St=s](5)
上式得到了两项,我们分别来推导。先看第一项。

标准的奖励函数形式为:
R ( s , a , s ′ ) (6) R(s,a,s^\prime) \tag 6 R(s,a,s)(6)
即奖励跟当前状态、采取的动作和下一个状态有关。假设奖励的取值是有限的 r ∈ R r \in \mathcal R rR,那么第一项可以写成:
E [ R t + 1 ∣ S t = s ] = ∑ r ∈ R r ⋅ p ( r ∣ s ) (7) \Bbb E[R_{t+1} |S_t=s] = \sum_{r \in \mathcal R} r \cdot p(r|s) \tag 7 E[Rt+1St=s]=rRrp(rs)(7)
我们可以根据条件边缘化(可以简单地把公共条件 s s s遮住来理解)把其中的 p ( r ∣ s ) p(r|s) p(rs)写成标准形式:
p ( r ∣ s ) = ∑ s ′ ∈ S ∑ a ∈ A p ( s ′ , a , r ∣ s ) (8) p(r|s) = \sum_{s^\prime \in \mathcal S} \sum_{a \in \mathcal A} p(s^\prime, a, r|s)\tag 8 p(rs)=sSaAp(s,a,rs)(8)
这里解释一下条件边缘化,回顾条件概率定义:
p ( A ∣ B ) = p ( A , B ) p ( B ) (S1.1) p(A|B) = \frac{p(A,B)}{p(B)} \tag{S1.1} p(AB)=p(B)p(A,B)(S1.1)
即:
p ( A , B ) = p ( A ∣ B ) p ( B ) (S1.2) p(A,B) = p(A|B)p(B) \tag {S1.2} p(A,B)=p(AB)p(B)(S1.2)
p ( s ′ , a , r ∣ s ) p(s^\prime, a, r|s) p(s,a,rs)展开,根据条件概率定义有:
p ( s ′ , a , r ∣ s ) = p ( s ′ , a , r , s ) p ( s ) (S1.3) p(s^\prime, a, r|s) = \frac{p(s^\prime, a, r,s)}{p(s)} \tag{S1.3} p(s,a,rs)=p(s)p(s,a,r,s)(S1.3)
边缘化的基本公式告诉我们:
p ( r , s ) = ∑ s ′ , a p ( s ′ , a , r , s ) (S1.4) p(r,s) = \sum_{s^\prime, a} p(s^\prime, a, r, s) \tag {S1.4} p(r,s)=s,ap(s,a,r,s)(S1.4)
p ( r ∣ s ) p(r|s) p(rs)可以写成:
p ( r ∣ s ) = p ( r , s ) p ( s ) (S1.5) p(r|s) = \frac{p(r,s)}{p(s)} \tag {S1.5} p(rs)=p(s)p(r,s)(S1.5)
把(S1.4)带入上式:
p ( r ∣ s ) = ∑ s ′ , a p ( s ′ , a , r , s ) p ( s ) = ∑ s ′ , a p ( s ′ , a , r ∣ s ) p ( s ) p ( s ) = ∑ s ′ , a p ( s ′ , a , r ∣ s ) (S1.6) \begin{aligned} p(r|s) &= \frac{ \sum_{s^\prime, a} p(s^\prime, a, r, s)}{p(s)} \\ &= \frac{ \sum_{s^\prime, a} p(s^\prime, a, r|s)p(s)}{p(s)} \\ &= \sum_{s^\prime, a} p(s^\prime, a, r|s) \end{aligned} \tag {S1.6} p(rs)=p(s)s,ap(s,a,r,s)=p(s)s,ap(s,a,rs)p(s)=s,ap(s,a,rs)(S1.6)
针对(8)我们可以拆出策略 p ( a ∣ s ) = π ( a ∣ s ) p(a|s)=\pi(a|s) p(as)=π(as)
p ( r ∣ s ) = ∑ s ′ ∈ S ∑ a ∈ A p ( s ′ , a , r ∣ s ) = ∑ s ′ ∈ S ∑ a ∈ A p ( a ∣ s ) p ( s ′ , r ∣ s , a ) = ∑ s ′ ∈ S ∑ a ∈ A π ( a ∣ s ) p ( s ′ , r ∣ s , a ) (9) p(r|s) = \sum_{s^\prime \in \mathcal S} \sum_{a \in \mathcal A} p(s^\prime, a, r|s)= \sum_{s^\prime \in \mathcal S} \sum_{a \in \mathcal A} p(a|s)p(s^\prime, r|s,a) = \sum_{s^\prime \in \mathcal S} \sum_{a \in \mathcal A} \pi(a|s)p(s^\prime, r|s,a) \tag 9 p(rs)=sSaAp(s,a,rs)=sSaAp(as)p(s,rs,a)=sSaAπ(as)p(s,rs,a)(9)
合并回公式(7):
E [ R t + 1 ∣ S t = s ] = ∑ r ∈ R r ⋅ p ( r ∣ s ) = ∑ r ∈ R ∑ s ′ ∈ S ∑ a ∈ A r ⋅ π ( a ∣ s ) p ( s ′ , r ∣ s , a ) (10) \Bbb E[R_{t+1} |S_t=s] = \sum_{r \in \mathcal R} r \cdot p(r|s) = \sum_{r \in \mathcal R}\sum_{s^\prime \in \mathcal S} \sum_{a \in \mathcal A} r \cdot \pi(a|s)p(s^\prime, r|s,a) \tag{10} E[Rt+1St=s]=rRrp(rs)=rRsSaArπ(as)p(s,rs,a)(10)
对于第二项 E [ γ G t + 1 ∣ S t = s ] = γ E [ G t + 1 ∣ S t = s ] \Bbb E[ \gamma G_{t+1}|S_t=s] = \gamma \Bbb E[ G_{t+1}|S_t=s] E[γGt+1St=s]=γE[Gt+1St=s],其中
E [ G t + 1 ∣ S t = s ] = ∑ g g ⋅ p ( g ∣ s ) (11) \Bbb E[ G_{t+1}|S_t=s] = \sum_g g\cdot p(g|s) \tag{11} E[Gt+1St=s]=ggp(gs)(11)
这里的 g g g代表的是 G t + 1 G_{t+1} Gt+1可能取到的每一个数值。和第一项一样,我们分解 p ( g ∣ s ) p(g|s) p(gs)
p ( g ∣ s ) = ∑ r ∈ R ∑ s ′ ∈ S ∑ a ∈ A p ( s ′ , r , a , g ∣ s ) (12) p(g|s) = \sum_{r \in \mathcal R}\sum_{s^\prime \in \mathcal S} \sum_{a \in \mathcal A} p(s^\prime,r,a,g|s) \tag{12} p(gs)=rRsSaAp(s,r,a,gs)(12)
将其分解为边缘部分:
p ( s ′ , r , a , g ∣ s ) = p ( s ′ , r , a ∣ s ) p ( g ∣ s ′ , r , a , s ) (13) p(s^\prime,r,a,g|s) = p(s^\prime,r,a|s)p(g|s^\prime,r,a,s) \tag{13} p(s,r,a,gs)=p(s,r,as)p(gs,r,a,s)(13)

这里分解的意思是在状态 s s s

  • 首先,做动作 a a a,跳到 s ′ s^\prime s,得到奖励 r r r,这一整套事情的概率是 p ( s ′ , r , a ∣ s ) p(s^\prime,r,a|s) p(s,r,as)
  • 然后,在这之后未来累积到的回报是 g g g,这个条件概率是 p ( g ∣ s ′ , r , a , s ) p(g|s^\prime,r,a,s) p(gs,r,a,s)

两者乘起来就是整个一条链上

  • s s s
  • 经过 a , s ′ , r a,s^\prime,r a,s,r
  • 最后回报是 g g g

这种分解是为了后面可以递归推导贝尔曼方程。

从公式(9)我们知道 p ( s ′ , r , a ∣ s ) = π ( a ∣ s ) p ( s ′ , r ∣ s , a ) p(s^\prime,r,a|s)=\pi(a|s)p(s^\prime,r|s,a) p(s,r,as)=π(as)p(s,rs,a),带入公式(13):
p ( g ∣ s ) = ∑ r ∈ R ∑ s ′ ∈ S ∑ a ∈ A π ( a ∣ s ) p ( s ′ , r ∣ s , a ) p ( g ∣ s ′ , r , a , s ) (14) p(g|s) = \sum_{r \in \mathcal R}\sum_{s^\prime \in \mathcal S} \sum_{a \in \mathcal A} \pi(a|s)p(s^\prime,r|s,a)p(g|s^\prime,r,a,s) \tag{14} p(gs)=rRsSaAπ(as)p(s,rs,a)p(gs,r,a,s)(14)
基于马尔可夫性质,未来的动作和它们带来的奖励仅依赖于当前的状态,因此:
p ( g ∣ s ′ , r , a , s ) = p ( g ∣ s ′ ) (15) p(g|s^\prime,r,a,s) = p(g|s^\prime) \tag {15} p(gs,r,a,s)=p(gs)(15)

代入(14)得:
p ( g ∣ s ) = ∑ r ∈ R ∑ s ′ ∈ S ∑ a ∈ A π ( a ∣ s ) p ( s ′ , r ∣ s , a ) p ( g ∣ s ′ ) (16) p(g|s) = \sum_{r \in \mathcal R}\sum_{s^\prime \in \mathcal S} \sum_{a \in \mathcal A} \pi(a|s)p(s^\prime,r|s,a)p(g|s^\prime) \tag{16} p(gs)=rRsSaAπ(as)p(s,rs,a)p(gs)(16)

把上式代入公式(11):
E [ G t + 1 ∣ S t = s ] = ∑ g g ⋅ p ( g ∣ s ) = ∑ r ∈ R ∑ s ′ ∈ S ∑ a ∈ A π ( a ∣ s ) p ( s ′ , r ∣ s , a ) ∑ g g ⋅ p ( g ∣ s ′ ) = ∑ r ∈ R ∑ s ′ ∈ S ∑ a ∈ A π ( a ∣ s ) p ( s ′ , r ∣ s , a ) V π ( s ′ ) (17) \begin{aligned} \Bbb E[ G_{t+1}|S_t=s] &= \sum_g g\cdot p(g|s) \\ &= \sum_{r \in \mathcal R}\sum_{s^\prime \in \mathcal S} \sum_{a \in \mathcal A} \pi(a|s)p(s^\prime,r|s,a)\sum_g g\cdot p(g|s^\prime) \\ &=\sum_{r \in \mathcal R}\sum_{s^\prime \in \mathcal S} \sum_{a \in \mathcal A} \pi(a|s)p(s^\prime,r|s,a)V^\pi(s^\prime) \end{aligned} \tag{17} E[Gt+1St=s]=ggp(gs)=rRsSaAπ(as)p(s,rs,a)ggp(gs)=rRsSaAπ(as)p(s,rs,a)Vπ(s)(17)
这里利用了 ∑ g g ⋅ p ( g ∣ s ′ ) = E [ G t + 1 ∣ S t + 1 = s ′ ] = V π ( s ′ ) \sum_g g \cdot p(g|s^\prime) = \Bbb E[G_{t+1}|S_{t+1}=s^\prime] = V^\pi(s^\prime) ggp(gs)=E[Gt+1St+1=s]=Vπ(s),为从 s ′ s^\prime s开始的期望总回报。

E [ γ G t + 1 ∣ S t = s ] = γ E [ G t + 1 ∣ S t = s ] \Bbb E[ \gamma G_{t+1}|S_t=s] =\gamma\Bbb E[ G_{t+1}|S_t=s] E[γGt+1St=s]=γE[Gt+1St=s]。把这两项的结果带入公式(4)中:
V π ( s ) = E [ R t + 1 + γ G t + 1 ∣ S t = s ] = E [ R t + 1 ∣ S t = s ] + E [ γ G t + 1 ∣ S t = s ] = ∑ r ∈ R ∑ s ′ ∈ S ∑ a ∈ A r ⋅ π ( a ∣ s ) p ( s ′ , r ∣ s , a ) + ∑ r ∈ R ∑ s ′ ∈ S ∑ a ∈ A γ π ( a ∣ s ) p ( s ′ , r ∣ s , a ) V π ( s ′ ) = ∑ r ∈ R ∑ s ′ ∈ S ∑ a ∈ A π ( a ∣ s ) p ( s ′ , r ∣ s , a ) ( r + γ V π ( s ′ ) ) = ∑ a ∈ A π ( a ∣ s ) ∑ r ∈ R ∑ s ′ ∈ S p ( s ′ , r ∣ s , a ) ( r + γ V π ( s ′ ) ) (18) \begin{aligned} V^\pi(s) &= \Bbb E[R_{t+1} + \gamma G_{t+1}|S_t=s] \\ &= \Bbb E[R_{t+1} |S_t=s] + \Bbb E[ \gamma G_{t+1}|S_t=s] \\ &= \sum_{r \in \mathcal R}\sum_{s^\prime \in \mathcal S} \sum_{a \in \mathcal A} r \cdot \pi(a|s)p(s^\prime, r|s,a) + \sum_{r \in \mathcal R}\sum_{s^\prime \in \mathcal S} \sum_{a \in \mathcal A} \gamma\pi(a|s)p(s^\prime,r|s,a)V^\pi(s^\prime) \\ &= \sum_{r \in \mathcal R}\sum_{s^\prime \in \mathcal S} \sum_{a \in \mathcal A} \pi(a|s)p(s^\prime,r|s,a)(r + \gamma V^\pi(s^\prime)) \\ &= \sum_{a \in \mathcal A} \pi(a|s) \sum_{r \in \mathcal R}\sum_{s^\prime \in \mathcal S}p(s^\prime,r|s,a)\left(r + \gamma V^\pi(s^\prime) \right) \end{aligned} \tag{18} Vπ(s)=E[Rt+1+γGt+1St=s]=E[Rt+1St=s]+E[γGt+1St=s]=rRsSaArπ(as)p(s,rs,a)+rRsSaAγπ(as)p(s,rs,a)Vπ(s)=rRsSaAπ(as)p(s,rs,a)(r+γVπ(s))=aAπ(as)rRsSp(s,rs,a)(r+γVπ(s))(18)

需要在状态空间 S \mathcal S S中的所有 s s s上应用该公式。

动作价值函数

同理可以推导出动作价值函数贝尔曼方程的递推式子。

q π ( s , a ) = E [ G t ∣ S t = s , A t = a ] (19) q_\pi(s,a) = \Bbb E[G_t|S_t=s, A_t=a] \tag{19} qπ(s,a)=E[GtSt=s,At=a](19)

q π ( s , a ) = E [ R t + 1 + γ G t + 1 ∣ S t = s , A t = a ] (20) q_\pi(s,a) = \Bbb E[R_{t+1} + \gamma G_{t+1}|S_t=s, A_t=a] \tag{20} qπ(s,a)=E[Rt+1+γGt+1St=s,At=a](20)

E [ R t + 1 ∣ S t = s , A t = a ] = ∑ s ′ ∈ S ∑ r ∈ R r ⋅ p ( s ′ , r ∣ s , a ) (21) \Bbb E[R_{t+1} |S_t=s,A_t=a] = \sum_{s^\prime \in \mathcal S}\sum_{r \in \mathcal R} r \cdot p(s^\prime, r|s,a) \tag{21} E[Rt+1St=s,At=a]=sSrRrp(s,rs,a)(21)

E [ G t + 1 ∣ S t = s , A t = a ] = ∑ g g ⋅ p ( g ∣ s , a ) = ∑ s ′ ∈ S ∑ r ∈ R ∑ g g ⋅ p ( s ′ , r , g ∣ s , a ) = ∑ s ′ ∈ S ∑ r ∈ R ∑ g g ⋅ p ( s ′ , r ∣ s , a ) p ( g ∣ s ′ , r , s , a ) = ∑ s ′ ∈ S ∑ r ∈ R ∑ g g ⋅ p ( s ′ , r ∣ s , a ) p ( g ∣ s ′ ) = ∑ s ′ ∈ S ∑ r ∈ R p ( s ′ , r ∣ s , a ) ∑ g g ⋅ p ( g ∣ s ′ ) = ∑ s ′ ∈ S ∑ r ∈ R p ( s ′ , r ∣ s , a ) V π ( s ′ ) (22) \begin{aligned} \Bbb E[G_{t+1}|S_t=s, A_t=a] &= \sum_g g\cdot p(g|s,a) \\ &= \sum_{s^\prime \in \mathcal S}\sum_{r \in \mathcal R} \sum_g g\cdot p(s^\prime,r,g|s,a) \\ &= \sum_{s^\prime \in \mathcal S}\sum_{r \in \mathcal R} \sum_g g\cdot p(s^\prime,r|s,a)p(g|s^\prime,r,s,a) \\ &= \sum_{s^\prime \in \mathcal S}\sum_{r \in \mathcal R} \sum_g g\cdot p(s^\prime,r|s,a)p(g|s^\prime) \\ &= \sum_{s^\prime \in \mathcal S}\sum_{r \in \mathcal R} p(s^\prime,r|s,a) \sum_g g\cdot p(g|s^\prime) \\ &= \sum_{s^\prime \in \mathcal S}\sum_{r \in \mathcal R} p(s^\prime,r|s,a) V^\pi(s^\prime) \end{aligned} \tag{22} E[Gt+1St=s,At=a]=ggp(gs,a)=sSrRggp(s,r,gs,a)=sSrRggp(s,rs,a)p(gs,r,s,a)=sSrRggp(s,rs,a)p(gs)=sSrRp(s,rs,a)ggp(gs)=sSrRp(s,rs,a)Vπ(s)(22)

q π ( s , a ) = E [ R t + 1 + γ G t + 1 ∣ S t = s , A t = a ] = ∑ s ′ ∈ S ∑ r ∈ R r ⋅ p ( s ′ , r ∣ s , a ) + γ ∑ s ′ ∈ S ∑ r ∈ R p ( s ′ , r ∣ s , a ) V π ( s ′ ) = ∑ s ′ ∈ S ∑ r ∈ R p ( s ′ , r ∣ s , a ) ( r + γ V π ( s ′ ) ) (23) \begin{aligned} q_\pi(s,a) &= \Bbb E[R_{t+1} + \gamma G_{t+1}|S_t=s, A_t=a] \\ &= \sum_{s^\prime \in \mathcal S}\sum_{r \in \mathcal R} r \cdot p(s^\prime, r|s,a) + \gamma \sum_{s^\prime \in \mathcal S}\sum_{r \in \mathcal R} p(s^\prime,r|s,a) V^\pi(s^\prime) \\ &= \sum_{s^\prime \in \mathcal S}\sum_{r \in \mathcal R} p(s^\prime,r|s,a) (r + \gamma V^\pi(s^\prime)) \end{aligned} \tag{23} qπ(s,a)=E[Rt+1+γGt+1St=s,At=a]=sSrRrp(s,rs,a)+γsSrRp(s,rs,a)Vπ(s)=sSrRp(s,rs,a)(r+γVπ(s))(23)

http://www.dtcms.com/wzjs/151599.html

相关文章:

  • wordpress 相册浏览器google seo实战教程
  • 东莞网站建设企业响应式网站建设
  • 长春比较有名的做网站建设工具大全
  • 广告公司网站源码最近爆发什么病毒感染
  • 东莞外贸网站建设开发苏州百度推广开户
  • 一级a做爰网站中国百度关键词热度排名
  • 集团培训网站建设关键词搜索技巧
  • 老的网站为什么要改版新网站国外b站浏览器
  • 福州网站搭建白帽优化关键词排名seo
  • 廊坊网站建设公司费用优化关键词的方法
  • 秦皇岛做网站多少钱键词优化排名
  • 哈尔滨做平台网站平台公司哪家好金华网站建设
  • 视频分享网站怎么做的写软文一篇多少钱合适
  • 多语种外贸网站管理系统宁波seo营销
  • 商城源码哪个品牌好百度排名优化咨询电话
  • wordpress手赚推广网站优化排名哪家好
  • 自己做网站模版百度付费推广
  • 销售一个产品的网站怎么做百度首页的ip地址
  • 国家卫生健康委健康中心百度搜索推广优化师工作内容
  • 58同城做网站的电话小红书推广平台
  • 做网站图片要求高吗创建网站免费
  • 网站建设注意事项 南京怎么用网络推广业务
  • 注册公司登陆哪个网站易推广
  • vs做的小型网站例青岛网站快速排名提升
  • 八方资源网的免费b2b网站营销型网站名词解释
  • 凡科做网站要钱泉州seo按天收费
  • 网站防采集专业seo整站优化
  • 电子商务网站建设与规划视频广东深圳疫情最新消息今天
  • 开封网站建设zducm中国软文网官网
  • 怎么免费网做百度收录的网站吗百度站长