CS285 2023Fall HW1

前言

你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Markdown编辑器, 可以仔细阅读这篇文章,了解一下Markdown的基本语法知识。

Analysis

Q1.

在这里插入图片描述

分析:给出的条件实际上是Lecture2里提到的General Analysis的弱化版本,在Lecture中,实际上规定了在每一个时间步t,对当前时间步任意状态 s t s_t st都有 π θ ( a t ≠ π ∗ ( s t ) ∣ s t ) ≤ ϵ \pi_\theta(a_t\neq \pi^*(s_t)|s_t)\leq\epsilon πθ(at=π(st)st)ϵ,而在这个问题中,该条件弱化为了对任意时间步、任意状态的期望,这实际上是两个期望,一个是对时间的平均(也可以理解为期望),另一个是对每个时间下状态的期望。根据下面的Hint,提示我们大概要构造期望,并用到一个和概率有关的union bound不等式,下面我们来求解。

在这里插入图片描述

首先我们模仿Lecture的内容,对于一个时间步骤 t t t,我们任取一个状态 s t s_t st,为了方便后面的书写,我们先定义一个概率,即截至t时间步内,策略 π θ \pi_\theta πθ与最优策略完全相同的概率:
p c o r r e c t = ( 1 − P r ( ⋃ t = 1 t π θ ( a t ) ≠ π ∗ ( a t ) ) ) (1) p_{correct}=(1-Pr(\bigcup_{t=1}^t\pi_\theta(a_t)\neq\pi^* (a_t)))\tag{1} pcorrect=(1Pr(t=1tπθ(at)=π(at)))(1)
从而得到以下概率表示,这实际上是Lecture的公式的变形。
p π θ ( s t ) = p c o r r e c t p π ∗ ( s t ) + ( 1 − p c o r r e c t ) p w r o n g ( s t ) (2) p_{\pi_\theta}(s_t)=p_{correct}p_{\pi^*}(s_t) + (1-p_{correct})p_{wrong}(s_t)\tag{2} pπθ(st)=pcorrectpπ(st)+(1pcorrect)pwrong(st)(2)
因此,采用与Lecture中相同的方式,我们可以得到:
∣ p π θ ( s t ) − p π ∗ ( s t ) ∣ = ( 1 − p c o r r e c t ) ∣ p w r o n g ( s t ) − p π ∗ ( s t ) ∣ (3) |p_{\pi_\theta}(s_t)-p_{\pi^*}(s_t)|=(1-p_{correct})|p_{wrong}(s_t)-p_{\pi^*}(s_t)|\tag{3} pπθ(st)pπ(st)=(1pcorrect)pwrong(st)pπ(st)(3)
这里我们就已经得到了一个初步的表达式了,根据绝对值的性质,证明结论里的常数2已经凑出来了( ∣ p w r o n g ( s t ) − p π ∗ ( s t ) ∣ ≤ 2 |p_{wrong}(s_t)-p_{\pi^*}(s_t)|\leq 2 pwrong(st)pπ(st)2)。我们先将这个搁置一边,这里我们先尝试分析 p c o r r e c t p_{correct} pcorrect,根据Hint2有
p c o r r e c t ≥ 1 − ∑ t = 1 t P r ( π θ ( a t ) ≠ π ∗ ( a t ) ) = 1 − ∑ t = 1 t p ( s t ) π θ ( a t ≠ π ∗ ( s t ) ∣ s t ) (4) p_{correct}\geq1-\sum_{t=1}^tPr(\pi_\theta(a_t)\neq\pi^* (a_t))=1-\sum_{t=1}^tp(s_t)\pi_\theta(a_t\neq\pi^*(s_t)|s_t)\tag{4} pcorrect1t=1tPr(πθ(at)=π(at))=1t=1tp(st)πθ(at=π(st)st)(4)
从而我们就得到:
∣ p π θ ( s t ) − p π ∗ ( s t ) ∣ ≤ ( ∑ t = 1 t p ( s t ) π θ ( a t ≠ π ∗ ( s t ) ∣ s t ) ) ∣ p w r o n g ( s t ) − p π ∗ ( s t ) ∣ (5) |p_{\pi_\theta}(s_t)-p_{\pi^*}(s_t)|\leq(\sum_{t=1}^tp(s_t)\pi_\theta(a_t\neq\pi^*(s_t)|s_t))|p_{wrong}(s_t)-p_{\pi^*}(s_t)|\tag{5} pπθ(st)pπ(st)(t=1tp(st)πθ(at=π(st)st))pwrong(st)pπ(st)(5)
如果左右对这时,再利用前文提到的前置条件,并取t=T即可得到。
不过说实话,这里其实存在一些细节问题,比如eq4的化简中,实际上暗含着一个状态序列 ( s 1 , s 2 , . . , s t ) (s_1, s_2, .., s_t) (s1,s2,..,st),也就是说,实际上我们是假定了这个序列是前取好的。最后一步对状态求和的过程中,我不确定这种提前取好的序列是否能说的通。这里对于结果有异议的同学,或许可以想一下这个思路。对任何一个时间步t,实际上如果我们取遍其 s t s_t st,那么都应该是等于期望的,因此最后一步的求和可能能解释的通是一个期望。

Q2.

在这里插入图片描述
(1)如果reward只取决于 s t s_t st,则可以化简为:
J ( π ) = ∑ i = 1 T E p π ( s t ) r ( s t ) = E p π ( s T ) r ( s T ) J(\pi)=\sum_{i=1}^TE_{p_{\pi(s_t)}}r(s_t)=E_{p_{\pi(s_T)} }r(s_T) J(π)=i=1TEpπ(st)r(st)=Epπ(sT)r(sT)
因此,有:
J ( π ∗ ) − J ( π θ ) = E p π ∗ ( s T ) r ( s T ) − E p π θ ( s T ) r ( s T ) ≤ 2 ϵ T R m a x = O ( T ϵ ) J(\pi^*)-J(\pi_\theta)=E_{p_{\pi^*(s_T)} }r(s_T)-E_{p_{\pi_\theta(s_T)} }r(s_T)\leq2\epsilon TR_{max}=\mathcal{O}(T\epsilon) J(π)J(πθ)=Epπ(sT)r(sT)Epπθ(sT)r(sT)2ϵTRmax=O(Tϵ)
(2)同理,因为有求和,所以是 O ( T 2 ϵ ) \mathcal{O}(T^2\epsilon) O(T2ϵ)

Code

待更新

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐