This is meant to be a readable explanation of KFAC and EKFAC.
KFAC
Kronecker-Factored Approximate Curvature (KFAC), introduced by Martens and Grosse, is a method to approximate the Fisher Information Matrix (FIM). This is often useful for computing influence functions, where we need to invert a large Hessian. This is costly, so we seek to approximate the Hessian via the Gauss-Newton Hessian JTHyJ.
Fact. The FIM equals the expected Hessian of the negative log-likelihood (where the expectation is taken over y∼p(y∣x;θ)). This expected Hessian coincides with the Gauss-Newton Hessian JTHyJ.
So approximating the FIM Ex∼pdata(x),y∼p(y∣x;θ)[(∇θlogp(y∣x;θ))(∇θlogp(y∣x;θ))T] as an efficiently invertible matrix allows us to also efficiently invert the Hessian.
Approximating the FIM
Consider the gradient of the logprobs w.r.t. a certain layer l's weights ∇Wllogp(y∣x,θ). By the chain rule:
Here we used the mixed product property (A⊗B)⋅(C⊗D)=AC⊗BD and that (u⊗v)T=uT⊗vT.
To simplify this expression, we make the following assumption: al−1 and ∇zllogp(y∣x;θ) are independent, i.e. when taking the expected value over many examples, al−1 doesn't provide much information about ∇zllogp(y∣x;θ).
Remark. This assumption is not accurate in practice, and can cause trouble. This is why we need eigenvalue correction!
This assumption allows us to separate the expected value:
Designating the first matrix Al−1 and the second Bl, we have:
Fl=Al−1⊗Bl
Note that we have obtained the FIM only for a single layer l. The FIM for the entire network is a block matrix:
F=F11F21F31F12F22F32F13F23F33
Here, we make another assumption: that F is block-diagonal, i.e. Fij=0 when i=j. This means that for any two layers l and k, we are assuming the following:
E[(∇θllogp(y∣x;θ))(∇θklogp(y∣x;θ))T]=0
Then we can assemble F as:
F=blockdiag(F1,F2,...,FL)
Eigenvalue-Corrected KFAC
(Spectral Theorem for Real Symmetric Matrices). Let V be a real inner product space with dim(V)<∞, and S:V→V be a symmetric linear map so that S=ST. Then S is normal (SST=S2=STS) and admits an orthonormal basis of eigenvectors.
Remark. In this section, I write A=Al−1 and B=Bl for simplicity's sake.
Notice that A and B are real symmetric matrices. Therefore, by the spectral theorem, they admit orthonormal bases of eigenvectors, which means we can diagonalize them:
A=PAΛAPATB=PBΛBPBT
where PA and PB are orthogonal, i.e. PA⋅PAT=PAT⋅PA=I i.e. PAT=PA−1
This means that the matrix ΛA⊗ΛB contains the eigenvalues of Fl.
Problem. What happens if these eigenvalues are wrong because the independence assumption we made earlier was imperfect?
Solution. We compute the eigenvalues of Fl directly, i.e. a matrix Λ which is not necessarily equal to ΛA⊗ΛB.
To do this, we project the gradient onto the columns of PA⊗PB, i.e. our (assumed) eigenbasis for Fl and take the expected value of the squared projection.
First, recall the expression for the general quadratic form of a column vector x: q(x)=xTMx. Now with M=Fl, we have:
Note that for an eigenvector x of M such that ∥x∥=1, xTMx=λxTx=λ. Since the columns of the matrix PA⊗PB are orthonormal eigenvectors, we can assemble Λ as follows:
Λii=E[([(PA⊗PB)T∇θllogp(y∣x;θ)]i)2]
This allows us to keep our convenient assumption about the eigenbasis while correcting the inaccurate eigenvalues.