# Computing Empirical Fisher Information matrix for natural gradient

I would like to implement the natural gradient for reinforcement learning as described in the following paper: https://arxiv.org/pdf/1703.02660.pdf

However, I do not know how to compute the empirical Fisher Information matrix to implement gradient ascent with the following parameter update $$\theta_{t+1} := \theta_t + F^{-1}\nabla_\theta J(\pi_\theta)$$, where $$\nabla_\theta J(\pi_\theta)$$ is the regular policy gradient weighted by the advantages.

When computing the empirical Fisher Information as the outer product of the log policy gradient $$F = \frac{1}{T}\sum_{t=1}^T\nabla_{\theta}\, log\, \pi_\theta\, \nabla_{\theta}\, log\, \pi_\theta^\intercal$$ (summed over all trajectories/samples), the resulting Fisher matrix is not positive semidefinite.

I do not see any reason why the policy gradient $$\nabla_{\theta}\, log\, \pi\,$$ should not have negative components.

What is the right way to practically calculate the empirical Fisher information from the gradient in an implementation? Is it correct to directly use the outer product of the gradients (e.g. with numpy as F = np.outer(grad, grad)?

• I believe most, if not all, of the questions you pose may have been answered (albeit in a slightly different context) at stats.stackexchange.com/questions/7308/…. Does that help? – whuber Mar 4 '19 at 18:52
• Thank you! This does answer some of my questions. But I am wondering whether there are better ways to implement the natural gradient than literally computing the outer product of the log policy gradient (equation 3.11 in this paper: citeseerx.ist.psu.edu/viewdoc/…). – cookiedealer Mar 5 '19 at 18:03
• Would you mind editing your post to focus on that issue? That might encourage people to post appropriate answers. – whuber Mar 5 '19 at 18:07
• Thanks, I updated the question, let me know if more details are necessary at any point – cookiedealer Mar 5 '19 at 18:27