Bayesian statistics 視 dataset D={x1,...,xn} 為固定, 而 model parameter θ 為 random variables, 透過假設 prior p(θ), 利用 Bayes rule 可得 posterior p(θ|D). 而估計的參數就是 posterior 的 mode, i.e. θmap (Maximum A Posterior, MAP)
關於 Fisher information matrix 在 Bayesian 觀點的用途, 其中一個為幫助定義一個特殊的 prior distribution (Jeffreys prior), 使得如果 parameter θ 重新定義成 ϕ, 例如 ϕ=f(θ), 則 MAP 解不會改變. 關於這部分還請參考 Machine Learning: a Probabilistic Perspective by Kevin Patrick Murphy. Chapters 5 的 Figure 5.2 圖很清楚
反之 Frequentist statistics 視 dataset D={X1,...,Xn} 為 random variables, 透過真實 θ∗ 採樣出 K 組 datasets, 每一組 dataset Dk 都可以求得一個 θkmle (MLE 表示 Maximum Likelihood Estimator), 則 θkmle 跟 θ∗ 的關係可藉由 Fisher information matrix 看出來
本文探討 score function 和 Fisher information matrix 的定義, 重點會放在怎麼直觀理解. 然後會說明 Fisher information matrix 在 Frequentist statistics 角度代表什麼意義.
先定義一波
Score Function
[Score Function Definition]:
針對某一點 data point x, 在 ˆθ 點的 log-likelihood 的 gradient 定義為 score function:
s(x,ˆθ)≜∇θlogp(x|ˆθ)
注意到如果 x 是 random variables, s(x,ˆθ) 也會是 random variable
在 Frequentist statistics 觀點下, data x 是 random variables, 所以可以對 true parameter θ∗ 的 data distribution p(x|θ∗) 計算期望值:
Ep(x|θ∗)[s(x,ˆθ)]=∫p(x|θ∗)∇θlogp(x|ˆθ)dx
我們舉個離散的例子來說明式 (2):
可以看到 score function 相當於在描述 parameter 變化對於 log-likelihood 的變化程度.
而該變化程度在真實 θ∗ 那點的期望值為 0, i.e. 在 ˆθ=θ∗ 這點計算 score function 的期望值:
Ep(x|θ∗)[s(x,θ∗)]=∫p(x|θ∗)∇θlogp(x|θ∗)dx=∫p(x|θ∗)∇θp(x|θ∗)p(x|θ∗)dx=∫∇θp(x|θ∗)dx=∇θ∫p(x|θ∗)dx=∇θ1=0
💡 注意到計算期望值都是基於真實資料分佈, i.e. p(x|θ∗). 為何強調這一點, 是因為我們手頭上的 training data 一般來說都是假設從真實分佈取樣出來的, 也就是說只要用 training data 計算期望值, 隱含的假設就是用 p(x|θ∗) 來計算.
因此我們有
Ep(x|θ∗)[s(x,θ∗)]=0
💡 其實對任何其他點 ˆθ 式 (3) 也成立, i.e. Ep(x|ˆθ)[s(x,ˆθ)]=0. 注意到期望值必須基於 p(x|ˆθ) 而非真實資料分佈了.
Fisher Information Matrix
💡 Ep(x|θ∗)[⋅] 我們簡寫為 Ep∗[⋅]
[Fisher Information Matrix Definition]:
在 ˆθ 點的 Fisher information matrix 定義為:
I(θ∗;ˆθ)=Ep∗[s(x,ˆθ)s(x,ˆθ)T]=Ep∗[∇θlogp(x|ˆθ)∇θlogp(x|ˆθ)T]
其中 θ∗ 為真實資料的參數
其實就是 score function 的 second moment.
Fisher information matrix 在 ˆθ=θ∗ 此點上為:
I(θ∗;θ∗)=Ep∗[(s(x,θ∗)−0)(s(x,θ∗)−0)T]=Ep∗[(s(x,θ∗)−Ep∗[s(x,θ∗)])(s(x,θ∗)−Ep∗[s(x,θ∗)])T]=Covp∗(s(x,θ∗),s(x,θ∗))
由於我們已經知道 score function 在 ˆθ=θ∗ 的期望值是 0 , 因此 Fisher information matrix 變成 Covariance matrix of score function
💡 同樣對任何其他點 ˆθ 式 (6) 也成立, i.e. I(ˆθ;ˆθ)=Covˆp(s(x,ˆθ),s(x,ˆθ)). 同樣注意到期望值必須基於 p(x|ˆθ) 而非真實資料分佈了.
示意圖為:
score_function_example_on_true_parameters.drawio
另外假如我們思考 score function (gradient) 計算的是一次微分, 可以想成是斜率. 那如果考慮二次微分 (Hseeian matrix), 則可想成是 curvature, 因此示意圖為:
Hessian_example_on_true_parameters.drawio
curvature_example.pptx
紅色的那三條 curves 就是 3 個 data points 的 Hessian matrices. 因此 Hessian matrix (at θ∗) 的期望值直觀上可以想成 log-likelihood 的 graph 在 θ∗ 的彎曲程度 (curvature).
以上這個觀點其實跟 Fisher information matrix 有關聯的, 描述如下:
“Fisher information matrix = score function 的 covariance matrix” 等於 “負的 Hessian matrix 之期望值”. 注意到這性質成立在 θ⋆. (或更精確地說, 任何 ˆθ 都滿足 I(ˆθ,ˆθ)=−Eˆp[H(x|ˆθ)], 只是期望值基於 p(x|ˆθ) 而不是真實資料分佈, 抱歉第三次囉嗦這一點, 不再強調了 XD)
證明可參考 Wiki 的 Fisher information, 或參考 Agustinus Kristiadi’s Blog: Fisher Information Matrix. 這裡就不重複.
本篇目的為了解其物理意義.
因此我們有如下的等式:
I(θ∗;θ∗)=Ep∗[∇θlogp(x|θ∗)∇θlogp(x|θ∗)T]=−Ep∗[∇2θlogp(x|θ∗)]
KL-divergence (or relative entropy) 與 MLE 與 I(θ∗;θ∗) 關聯
KL-divergence 為, 通常 p(x) 表示 ground truth distribution:
KL(p(x);q(x))=∫p(x)logp(x)q(x)dx
則我們知道 MLE (maximum log likelihood estimation) 等同於求解最小化 KL-divergence [ref]
argminθKL(p(x|θ∗);p(x|θ))=argminθ∫p(x|θ∗)logp(x|θ∗)p(x|θ)dx=argminθ∫p(x|θ∗)log1p(x|θ)dx=argminθ−Ep∗[logp(x|θ)]=:argminNLL=argmaxθEp∗[logp(x|θ)]=:θmle
其中 NLL 表示 Negative Log-Likelihood
由於我們已經知道 I(θ∗;θ∗) 描述了 NLL 的 curvature, 由剛剛的推導知道 NLL (就是 MLE) 跟 KL 等價, 所以 I(θ∗;θ∗) 也描述了 KL-divergence 的 curvature, 具體推導如下:
curvature of KL at θ∗=∇2θKL(p(x|θ∗);p(x|θ∗))=(∂2∂θi∂θjKL(p(x|θ∗);p(x|θ)))θ=θ∗=−∫p(x|θ∗)(∂2∂θi∂θjlogp(x|θ))θ=θ∗dx=−Ep∗[∇2θlogp(x|θ∗)]by (7) =I(θ∗;θ∗)
I(θ∗;θ∗) 在 Frequentist statistics 的解釋
了解了 Fisher information matrix 的物理意義後, 還能給我們什麼洞見?
回到文章開頭說的:
Frequentist statistics 視 dataset D={X1,...,Xn} 為 random variables, 透過真實 θ∗ 採樣出 K 組 datasets, 每一組 dataset Dk (共 n 筆 data) 都可以求得一個 θkmle (MLE 表示 Maximum Likelihood Estimator)
所以可以視 θmle 為一個 random variables, 其 distribution 稱為 sampling distribution.
則 θmle 跟 θ∗ 有如下關係 (sampling distribution 為 Normal distribution) :
√n(θmle−θ∗)d→N(0,I−1(θ∗;θ∗)),as n→∞
其中 d→ 表示 converge in distribution. 又或者這麼寫
(θmle−θ)≈dN(0,1nI(θ∗;θ∗))
直觀解釋為如果 I(θ∗;θ∗) 愈大 (or n 愈大) , MLE 愈有高的機率接近 θ∗
因此 Fisher information matrix I(θ∗;θ∗) 量測了 MLE 的準確度
Summary
本文討論了 score function and Fisher information matrix 的定義和直觀解釋, 同時也說明了 MLE 的估計 θmle 其距離真實參數 θ∗ 可被 Fisher information matrix I(θ∗;θ∗) 描述出來 (雖然實務上我們無法算 I(θ∗;θ∗) 因為不知道 true parameters θ∗)
關於 Fisher information 知乎這篇文章很好: 费雪信息 (Fisher information) 的直观意义是什么?
同時 Fisher information 也能描述參數 θ 和 random variable x 之間的信息量 (這部分本文沒描述), 可參考 Maximum Likelihood Estimation (MLE) and the Fisher Information 和 A tutorial on Fisher information 利用 binomial distribution 的例子來說明
另外與 Natural gradient 的關聯可參考: Natural Gradient by Yuan-Hong Liao (Andrew). 寫得也非常棒! 在基於第 t 次的 θt 時, Natural gradient 要找得 optimize 方向 d∗ 為如下:
d∗=argminKL(p(x|θt)‖p(x|θt+d))=cL(θt+d)
d∗∝−I(θt;θt)−1∇θL(θ)|θ=θt
最後提一下, 本文定義的 score function 是基於 θ 的 gradient, 但同時有另一種方法稱 Score Matching [ref 9], 其定義的 score function 是基於 data point x 的 gradient:
∇xlogp(x;θ)
Reference
- Machine Learning: a Probabilistic Perspective by Kevin Patrick Murphy. Chapters 5 and 6
- Agustinus Kristiadi’s Blog: **Fisher Information Matrix
- Wiki Fisher information
- A tutorial on Fisher information [pdf]
- Maximizing likelihood is equivalent to minimizing KL-Divergence
- 费雪信息 (Fisher information) 的直观意义是什么?
- Maximum Likelihood Estimation (MLE) and the Fisher Information by Xichu Zhang
- Yang Song: Generative Modeling by Estimating Gradients of the Data Distribution
- Estimation of Non-Normalized Statistical Models by Score Matching
- Natural Gradient by Yuan-Hong Liao (Andrew)