Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

策略梯度证明笔误? #82

Open
lanceyliao opened this issue Aug 7, 2024 · 2 comments
Open

策略梯度证明笔误? #82

lanceyliao opened this issue Aug 7, 2024 · 2 comments

Comments

@lanceyliao
Copy link

lanceyliao commented Aug 7, 2024

9.6. 策略梯度证明

$$ \begin{aligned} \nabla_\theta V^{\pi_\theta}(s) &= \phi(s) + \gamma \sum_a \pi_\theta(a|s) \sum_{s'} p(s'|s, a) \nabla_\theta V^{\pi_\theta}(s')\\ &= \phi(s) + \gamma \sum_{s'} \sum_a \pi_\theta(a|s) p(s'|s, a) \nabla_\theta V^{\pi_\theta}(s')\\ &= \phi(s) + \gamma \sum_{s'} d^{\pi_\theta}(s \to s', 1) \nabla_\theta V^{\pi_\theta}(s')\\ &= \phi(s) + \gamma \sum_{s'} d^{\pi_\theta}(s \to s', 1)[\phi(s') + \gamma \sum_{s''} d^{\pi_\theta}(s' \to s'', 1)\nabla_\theta V^{\pi_\theta}(s'')]\\ &= \phi(s) + \gamma \sum_{s'} d^{\pi_\theta}(s \to s', 1)\phi(s') + \gamma^2 \sum_{s''} d^{\pi_\theta}(s \to s'', 2)\nabla_\theta V^{\pi_\theta}(s'')\\ &= \phi(s) + \gamma \sum_{s'} d^{\pi_\theta}(s \to s', 1)\phi(s') + \gamma^2 \sum_{s''} d^{\pi_\theta}(s \to s'', 2)\phi(s'') + \gamma^3 \sum_{s'''} d^{\pi_\theta}(s \to s''', 3)\nabla_\theta V^{\pi_\theta}(s''')\\ &= \cdots\\ &= \sum_{x \in \mathcal{S}} \sum_{k=0}^{\infty} \gamma^k d^{\pi_\theta}(s \to x, k)\phi(x) \end{aligned} $$

左侧为网站,右侧为应更正为的
image

@lanceyliao
Copy link
Author

lanceyliao commented Aug 7, 2024

13.5. 确定性策略梯度证明也是,为什么不用$s_0 \to s$,而用$s \to s'$?

$$
\begin{aligned}
\nabla_{\theta} J(\mu_{\theta}) &= \nabla_{\theta} \int_{S} \nu_{0}(s) V^{\mu_\theta}(s) ds \
&= \int_{S} \nu_{0}(s) \nabla_{\theta} V^{\mu_\theta}(s) ds \
(\text{代入} V^{\mu_\theta}(s)) &= \int_{S} \nu_{0}(s) \left( \int_{S} \sum_{t=0}^{\infty} \gamma^{t} p(s \to s', t, \mu_{\theta}) \nabla_{\theta} \mu_{\theta}(s') \nabla_{a} Q^{\mu_\theta}(s', a) \big|{a=\mu{\theta}(s')} ds' \right) ds \
(\text{交换积分顺序}) &= \int_{S} \left( \int_{S} \sum_{t=0}^{\infty} \gamma^{t} \nu_{0}(s) p(s \to s', t, \mu_{\theta}) ds \right) \nabla_{\theta} \mu_{\theta}(s') \nabla_{a} Q^{\mu_\theta}(s', a) \big|{a=\mu{\theta}(s')} ds' \
(\text{代回} \nu^{\mu_\theta}(s)) &= \int_{S} \nu^{\mu_\theta}(s') \nabla_{\theta} \mu_{\theta}(s') \nabla_{a} Q^{\mu_\theta}(s', a) \big|{a=\mu{\theta}(s')} ds' \
&= \mathbb{E}{s \sim \nu^{\mu\theta}} \left[ \nabla_{\theta} \mu_{\theta}(s) \nabla_{a} Q^{\mu_\theta}(s', a) \big|{a=\mu{\theta}(s')} \right]
\end{aligned}
$$

image

@NeoPek
Copy link

NeoPek commented Aug 21, 2024

13.5. 确定性策略梯度证明也是,为什么不用$s_0 \to s$,而用$s \to s'$?

$$ \begin{aligned} \nabla_{\theta} J(\mu_{\theta}) &= \nabla_{\theta} \int_{S} \nu_{0}(s) V^{\mu_\theta}(s) ds \ &= \int_{S} \nu_{0}(s) \nabla_{\theta} V^{\mu_\theta}(s) ds \ (\text{代入} V^{\mu_\theta}(s)) &= \int_{S} \nu_{0}(s) \left( \int_{S} \sum_{t=0}^{\infty} \gamma^{t} p(s \to s', t, \mu_{\theta}) \nabla_{\theta} \mu_{\theta}(s') \nabla_{a} Q^{\mu_\theta}(s', a) \big|{a=\mu{\theta}(s')} ds' \right) ds \ (\text{交换积分顺序}) &= \int_{S} \left( \int_{S} \sum_{t=0}^{\infty} \gamma^{t} \nu_{0}(s) p(s \to s', t, \mu_{\theta}) ds \right) \nabla_{\theta} \mu_{\theta}(s') \nabla_{a} Q^{\mu_\theta}(s', a) \big|{a=\mu{\theta}(s')} ds' \ (\text{代回} \nu^{\mu_\theta}(s)) &= \int_{S} \nu^{\mu_\theta}(s') \nabla_{\theta} \mu_{\theta}(s') \nabla_{a} Q^{\mu_\theta}(s', a) \big|{a=\mu{\theta}(s')} ds' \ &= \mathbb{E}{s \sim \nu^{\mu\theta}} \left[ \nabla_{\theta} \mu_{\theta}(s) \nabla_{a} Q^{\mu_\theta}(s', a) \big|{a=\mu{\theta}(s')} \right] \end{aligned} $$

image

这里用 s' 应该是为了对应原论文推导的习惯,但是我感觉这里应该确实是写错了,交换积分顺序那一步里面那个括号的结果有问题,根据原始论文的符号定义应该是 ν^(μ_θ)(s')
image
然后代回的那一步里面所有的 s' 就可以换成 s,这里感觉是笔者发现圆不回来偷了一步 😧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants