udpate ch4

This commit is contained in:
qiwang067
2022-08-19 16:09:31 +08:00
parent 0c44b6c23c
commit 9084eb65d1
11 changed files with 2 additions and 2 deletions

View File

@@ -302,7 +302,7 @@ $$
$$
(s_1,a_1,G_1),(s_2,a_2,G_2),\cdots,(s_T,a_T,G_T)
$$
然后针对每个动作计算梯度 $\nabla \ln \pi(a_t|s_t,\theta)$ 。在代码上计算时我们要获取神经网络的输出。神经网络会输出每个动作对应的概率值比如0.2、0.5、0.3),然后我们还可以获取实际的动作$a_t$把动作转成独热one-hot向量比如[0,1,0])与 $\log [0.2,0.5,0.3]$ 相乘就可以得到 $\ln \pi(a_t|s_t,\theta)$ 。
然后针对每个动作计算梯度 $\nabla \log \pi(a_t|s_t,\theta)$ 。在代码上计算时我们要获取神经网络的输出。神经网络会输出每个动作对应的概率值比如0.2、0.5、0.3),然后我们还可以获取实际的动作$a_t$把动作转成独热one-hot向量比如[0,1,0])与 $\log [0.2,0.5,0.3]$ 相乘就可以得到 $\log \pi(a_t|s_t,\theta)$ 。
<div align=center>
@@ -353,7 +353,7 @@ $$
<div align=center>图 4.18 策略梯度损失</div>
如图 4.19 所示,实际上我们在计算策略梯度损失的时候,要先对实际执行的动作取独热向量,再获取神经网络预测的动作概率,将它们相乘,我们就可以得到 $\ln \pi(a_t|s_t,\theta)$,这就是我们要构造的损失。因为我们可以获取整个回合的所有的轨迹,所以我们可以对这一条轨迹里面的每个动作都去计算一个损失。把所有的损失加起来,我们再将其“扔”给 Adam 的优化器去自动更新参数就好了。
如图 4.19 所示,实际上我们在计算策略梯度损失的时候,要先对实际执行的动作取独热向量,再获取神经网络预测的动作概率,将它们相乘,我们就可以得到 $\log \pi(a_t|s_t,\theta)$,这就是我们要构造的损失。因为我们可以获取整个回合的所有的轨迹,所以我们可以对这一条轨迹里面的每个动作都去计算一个损失。把所有的损失加起来,我们再将其“扔”给 Adam 的优化器去自动更新参数就好了。
<div align=center>

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 335 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 428 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 803 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 524 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 585 KiB

After

Width:  |  Height:  |  Size: 424 KiB