【强化学习的数学原理】第一课:基本概念

在这里插入图片描述

  • State:agent 相对 environment 的一个状态

    对于网格例子,他的State为 s 1 、 s 2 、 s 3... s1、s2、s3... s1s2s3...

  • State space:状态空间,为State的集合 S = { s i } i = 1 9 \mathcal{S}=\left\{s_i\right\}_{i=1}^9 S={si}i=19

  • Action:对于每个 State 其采取的行动

    类似于可以向 a 1 、 a 2 、 a 3... a1、a2、a3... a1a2a3...行走

    在这里插入图片描述

  • Action space: A ( s i ) = { a i } i = 1 5 \mathcal{A}\left(s_i\right)=\left\{a_i\right\}_{i=1}^5 A(si)={ai}i=15

  • State transition:在状态 s 1 s1 s1采取action a 2 a2 a2 s 1 ⟶ a 2 s 2 s_1 \stackrel{a_2}{\longrightarrow} s_2 s1a2s2;加入在状态 s 1 ⟶ a 1 s 1 s_1 \stackrel{a_1}{\longrightarrow} s_1 s1a1s1因为撞在了边界所以还是保持原来的。

  • Forbidden area:有两种情况

    • s 5 ⟶ a 2 s 6 s_5 \stackrel{a_2}{\longrightarrow} s_6 s5a2s6,能够进去的但会有惩罚(本课程考虑的)
    • s 5 ⟶ a 2 s 5 s_5 \stackrel{a_2}{\longrightarrow} s_5 s5a2s5,不能进去的
  • Tabular representation:可以用表格进行状态转移的表示

    在这里插入图片描述

  • State transition probability:使用概率进行状态转移
    p ( s 2 ∣ s 1 , a 2 ) = 1 p ( s i ∣ s 1 , a 2 ) = 0 ∀ i ≠ 2 \begin{aligned} & p\left(s_2 \mid s_1, a_2\right)=1 \\ & p\left(s_i \mid s_1, a_2\right)=0 \quad \forall i \neq 2 \end{aligned} p(s2s1,a2)=1p(sis1,a2)=0i=2

  • Policy:告诉agent我在哪个state应该采取怎样的action

    在这里插入图片描述

  • Mathematical representation: π \pi π在强化学习里是条件概率

    • 确定性策略
      π ( a 1 ∣ s 1 ) = 0 π ( a 2 ∣ s 1 ) = 1 π ( a 3 ∣ s 1 ) = 0 π ( a 4 ∣ s 1 ) = 0 π ( a 5 ∣ s 1 ) = 0 \begin{aligned} & \pi\left(a_1 \mid s_1\right)=0 \\ & \pi\left(a_2 \mid s_1\right)=1 \\ & \pi\left(a_3 \mid s_1\right)=0 \\ & \pi\left(a_4 \mid s_1\right)=0 \\ & \pi\left(a_5 \mid s_1\right)=0 \end{aligned} π(a1s1)=0π(a2s1)=1π(a3s1)=0π(a4s1)=0π(a5s1)=0

    • 不确定性策略
      π ( a 1 ∣ s 1 ) = 0 π ( a 2 ∣ s 1 ) = 0.5 π ( a 3 ∣ s 1 ) = 0.5 π ( a 4 ∣ s 1 ) = 0 π ( a 5 ∣ s 1 ) = 0 \begin{aligned} & \pi\left(a_1 \mid s_1\right)=0 \\ & \pi\left(a_2 \mid s_1\right)=0.5 \\ & \pi\left(a_3 \mid s_1\right)=0.5 \\ & \pi\left(a_4 \mid s_1\right)=0 \\ & \pi\left(a_5 \mid s_1\right)=0 \end{aligned} π(a1s1)=0π(a2s1)=0.5π(a3s1)=0.5π(a4s1)=0π(a5s1)=0

  • Tabular representation:策略也可以用表格表示

    在这里插入图片描述

  • reward:是一个实数,在做一个action后会得到的(可以认为是人与机器交互的接口)

    • 正数:鼓励的
    • 负数:不希望发生是一个惩罚
    • grid-word例子:
      • 逃出边界: r bound  = − 1 r_{\text {bound }}=-1 rbound =1
      • 进入forbidden地区: r forbid  = − 1 r_{\text {forbid }}=-1 rforbid =1
      • 进入target地区: r target  = + 1 r_{\text {target }}=+1 rtarget =+1
      • 其余操作: r = 0 r=0 r=0
  • trajectory:state-action-reward链,例如下图所示 s 1 ⟶ a 2 r = 0 s 2 ⟶ a 3 r = 0 s 5 ⟶ a 3 r = 0 s 8 ⟶ a 2 r = 1 s 9 s_1 \underset{r=0}{\stackrel{a_2}{\longrightarrow}} s_2 \underset{r=0}{\stackrel{a_3}{\longrightarrow}} s_5 \underset{r=0}{\stackrel{a_3}{\longrightarrow}} s_8 \underset{r=1}{\stackrel{a_2}{\longrightarrow}} s_9 s1r=0a2s2r=0a3s5r=0a3s8r=1a2s9

    在这里插入图片描述

  • return:针对trajectory而言,沿着这个trajectory所有的reward的总和

  • discounted return:假设按照以下trajectory进行,则无穷长的轨迹来说它会发散掉。

    在这里插入图片描述

     trajectory  = s 1 ⟶ a 2 s 2 ⟶ a 3 s 5 ⟶ a 3 s 8 ⟶ a 2 s 9 ⟶ a 5 s 9 ⟶ a 5 s 9 … \text { trajectory }=s_1 \stackrel{a_2}{\longrightarrow} s_2 \stackrel{a_3}{\longrightarrow} s_5 \stackrel{a_3}{\longrightarrow} s_8 \stackrel{a_2}{\longrightarrow} s_9 \stackrel{a_5}{\longrightarrow} s_9 \stackrel{a_5}{\longrightarrow} s_9 \ldots  trajectory =s1a2s2a3s5a3s8a2s9a5s9a5s9

     return  = 0 + 0 + 0 + 1 + 1 + 1 + ⋯ = ∞ \text { return }=0+0+0+1+1+1+\cdots=\infty  return =0+0+0+1+1+1+=

    • discount rate: γ ∈ [ 0 , 1 ) \gamma \in[0,1) γ[0,1),通过引入并与discounted return结合
       discounted return  = 0 + γ 0 + γ 2 0 + γ 3 1 + γ 4 1 + γ 5 1 + … = γ 3 ( 1 + γ + γ 2 + … ) = γ 3 1 1 − γ . \begin{aligned} \text { discounted return } & =0+\gamma 0+\gamma^2 0+\gamma^3 1+\gamma^4 1+\gamma^5 1+\ldots \\ & =\gamma^3\left(1+\gamma+\gamma^2+\ldots\right)=\gamma^3 \frac{1}{1-\gamma} . \end{aligned}  discounted return =0+γ0+γ20+γ31+γ41+γ51+=γ3(1+γ+γ2+)=γ31γ1.

      • 通过引入discount rate使得刚才发散掉变成一个有限的值
      • 平衡远或进的reward
        • γ \gamma γ接近于0,则reward接近于最近的
        • γ \gamma γ接近于1,则reward接近于更远的
  • episode(trial):依据trajectory最终停在了terminal states

    有些任务没有terminal states这样的任务称为continuting tasks。本课程将episode转变为continuting tasks。

    在这里插入图片描述

  • Markov decision process(MDP)

    • 集合

      • State: S S S
      • Action: A ( s ) A(s) A(s)
      • Reward: R ( s , a ) R(s,a) R(s,a)
    • 概率分布

      • p ( s ′ ∣ s , a ) p\left(s^{\prime} \mid s, a\right) p(ss,a):我当前在 s s s通过采取动作 a a a跳到 s ′ s' s概率多少
      • p ( r ∣ s , a ) p(r \mid s, a) p(rs,a):我当前状态 s s s,通过采取动作 a a a,获得奖励 r r r的概率
    • 策略: π ( a ∣ s ) \pi(a \mid s) π(as)我在状态s采取策略a的概率是多少

    • 马尔可夫性质:无记忆性
      p ( s t + 1 ∣ a t + 1 , s t , … , a 1 , s 0 ) = p ( s t + 1 ∣ a t + 1 , s t ) , p ( r t + 1 ∣ a t + 1 , s t , … , a 1 , s 0 ) = p ( r t + 1 ∣ a t + 1 , s t ) . \begin{aligned} & p\left(s_{t+1} \mid a_{t+1}, s_t, \ldots, a_1, s_0\right)=p\left(s_{t+1} \mid a_{t+1}, s_t\right), \\ & p\left(r_{t+1} \mid a_{t+1}, s_t, \ldots, a_1, s_0\right)=p\left(r_{t+1} \mid a_{t+1}, s_t\right) . \end{aligned} p(st+1at+1,st,,a1,s0)=p(st+1at+1,st),p(rt+1at+1,st,,a1,s0)=p(rt+1at+1,st).在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值