10.md 2.2 KB
Newer Older
X
updated  
xiaowei_xing 已提交
1 2 3 4
# Lecture 10 Advanced Policy Gradient

# 课时10 高级策略梯度 2019.02.11

X
test  
xiaowei_xing 已提交
5 6 7 8 9 10 11 12
## 1. 策略梯度的目标(Policy Gradient Objective)

在策略梯度中,我们将策略 $\pi_\theta$ 参数化,并使用环境中的经历直接来优化它。我们首先定义基于当前策略 $\pi_\theta$ 的轨迹的概率为 $\pi_\theta(\tau)$:

$$
\pi_\theta(\tau) = \pi_\theta(s_1,a_1,...,s_T,a_T)=P(s_1)\prod_{t=1}^T \pi_\theta(a_t|s_t)P(s_{t+1}|s_t,a_t),
$$

X
test  
xiaowei_xing 已提交
13 14
这里 $P(s_1)$ 为起始状态为 $s_1$ 的概率,$\pi_\theta(a_t|s_t)$ 为根据当前的策略在状态 $s_t$ 选择动作 $a_t$ 的概率,$P(s_{t+1}|s_t,a_t)$ 为在状态 $s_t$ 选择动作 $a_t$ 时,状态转移到 $s_{t+1}$ 的概率。注意,$\pi_\theta(\tau)$ 为轨迹的概率而 $\pi_\theta(a|s)$ 为给定状态时选择某个动作的概率。

X
test  
xiaowei_xing 已提交
15
和到目前为止我们讨论过的大多数其他 RL 目标类似,策略梯度的目标是最大化衰减奖励总和。
X
test  
xiaowei_xing 已提交
16 17

$$
X
test  
xiaowei_xing 已提交
18 19 20 21 22 23
\theta^* = \mathop{\arg\max}_{\theta} \mathbb{E} _{\tau\sim \pi _{\theta}(\tau)}[\sum_t \gamma^t r (s_t,a_t)]。
$$

我们将目标函数记为 $J(\theta)$,可以用蒙特卡洛方法估计 $J(\theta)$。我们用 $r(\tau)$ 来代表轨迹 $\tau$ 的衰减奖励总和。

$$
X
test  
xiaowei_xing 已提交
24
J(\theta) = \mathbb{E}_{\tau\sim \pi _{\theta}(\tau)}[\sum_t \gamma^t r (s_t,a_t)] = \int \pi _{\theta} (\tau) r(\tau) \text{d} \tau
X
test  
xiaowei_xing 已提交
25 26
$$

X
test  
xiaowei_xing 已提交
27
$$
X
test  
xiaowei_xing 已提交
28
 \approx \frac{1}{N}\sum_{i=1}^N \sum_{t=1}^T \gamma^t r(s_{i,t},a_{i,t}),
X
test  
xiaowei_xing 已提交
29 30
 $$

X
test  
xiaowei_xing 已提交
31
$$
X
test  
xiaowei_xing 已提交
32
\theta^* = \mathop{\arg\max}_\theta J(\theta)。
X
test  
xiaowei_xing 已提交
33 34
$$

X
test  
xiaowei_xing 已提交
35 36
我们定义 $P_\theta(s,a)$ 为 $(s,a)$ 出现在轨迹中的概率。注意,若时间步无穷大而且状态的平稳分布存在时,我们可以将 $P_\theta(s,a)$ 写为 $P_\theta(s,a)=d^{\pi_{\theta}}(s)\pi_{\theta}(a|s)$,这里 $d^{\pi_{\theta}}(s)$ 为遵照策略 $\pi_{\theta}$ 时的状态的平稳分布。

X
test  
xiaowei_xing 已提交
37
在无限时间步的情况下,我们有:
X
test  
xiaowei_xing 已提交
38
$$
X
test  
xiaowei_xing 已提交
39
\theta^{*} = \mathop{\arg\max}_{\theta}\sum _{t=1}^{\infty} \mathbb{E} _{(s,a) \sim P _{\theta}(s,a)}[\gamma^t r(s,a)]
X
test  
xiaowei_xing 已提交
40 41 42 43 44 45 46 47
$$

$$
= \mathop{\arg\max}_{\theta} \frac{1}{1-\gamma}\mathbb{E} _{(s,a) \sim P _{\theta}(s,a)}[r(s,a)]
$$

$$
= \mathop{\arg\max}_{\theta} \mathbb{E} _{(s,a) \sim P _{\theta}(s,a)}[r(s,a)]。
X
test  
xiaowei_xing 已提交
48
$$