Derivation of optimal baseline
Preliminiary
- Trace of Matrix
- here we have
The gradient is where
- is a
(k,1)
vector, same as the gradient - note or is also a
(k,1)
vector - Let , also a
(k,1)
vector
It is common to use trace to measure the total variance of a covariance matrix , and trace is also a scalar obejective function to be optimized:
Then we have
To optimize the variance, we need to set the gradient to zero:
To ensure the above equation holds, for any should satisfy:
- note: we just expand the expectation to state-wise form
The above equation can be easily solved to obtain the optimal baseline:
We can remove the weights from the above equation, and obtain the suboptimal baseline in a more concise form:
说一些证明过程中的感悟
这一章的证明其实不难,但是自己依然花了比较多的时间,其原因是自己一开始就把X的shape理解错成了(n,m)的matrix,原因很简单,就是自认为和之前在policy_gradient_proof中的的思想一样,思路是.shape=(n,m)⇒.shape=(n,m)⇒.shape=(n,m),但实际上直接这样想是错误的,原因如下:
- 在TL;DR的章节中的是基本按的操作的格式去一路写下去的,这也是为什么自己可以这样写:,这个过程是符合.shape=(n,m)⇒.shape=(n,m)的,这里的,但是policy_gradient_proof中除了TLDR这里的推导()以外,其他所有地方的.shape都是等于.shape的(因为最开头明确说明了)
- 本章节目的是针对参数(e.g.
(k,1)
vector),希望可以找到一条梯度下降的方法,既不改变原本下降的梯度,也可以使得对于而言这条路径梯度的方差不会太大(上面我们就是用trace将(k,k)的这个协方差矩阵的对角线上的协方差值加起来,正好变成一个scalar,去进而求关于b的梯度,得到b的最优解格式),这里的梯度应该是符合.shape=(k,1)⇒.shape=(k,1)总结就是说,
X.shape=theta.shape=(k,1)
才是正解,最开头关于X的定义式是element-wise的(即对于每个state每个action而言我们是展开写的式子,这里并不可以一眼就把直接就写成(n,m)
矩阵了,这样做下去会把问题复杂化)可以回顾这一节内容⇒ About the policy gradient