我是靠谱客的博主 结实画笔,这篇文章主要介绍机器学习笔记之高斯过程(二)高斯过程回归——权重空间角度引言,现在分享给大家,希望可以做个参考。

机器学习笔记之高斯过程——高斯过程回归[权重空间角度]

  • 引言
    • 回顾
      • 高斯过程
      • 贝叶斯线性回归
    • 引子:贝叶斯方法求解非线性回归任务
      • 均值表示的推导过程
      • 方差表示的推导过程
      • 协方差函数(核函数)
    • 高斯过程回归与线性贝叶斯回归的关系

引言

上一节简单介绍了高斯过程,本节将从权重空间角度(Weight-Space)介绍高斯过程回归

回顾

高斯过程

高斯过程(Gaussian Process)本质上是一组随机变量的集合,该集合中任意有限个随机变量均服从高斯分布。
定义基于时间/空间的连续域 为 T mathcal T T,对应高斯过程表示为: { ξ t } t ∈ T {xi_{t}}_{t in mathcal T} {ξt​}t∈T​。

  • 该随机过程中任意时刻 t ∈ T t in mathcal T t∈T对应的随机变量 ξ t ∈ { ξ t } t ∈ T xi_t in {xi_t}_{t in mathcal T} ξt​∈{ξt​}t∈T​均服从高斯分布 N ( μ t , Σ t ) mathcal N(mu_t,Sigma_t) N(μt​,Σt​)。
  • 并且,从高斯过程 { ξ t } t ∈ T {xi_t}_{t in mathcal T} {ξt​}t∈T​中任意选出 n n n个时刻对应的随机变量: { ξ t 1 , ξ t 2 , ⋯   , ξ t n } ∈ { ξ t } t ∈ T {xi_{t_1},xi_{t_2},cdots,xi_{t_n}} in {xi_t}_{t in mathcal T} {ξt1​​,ξt2​​,⋯,ξtn​​}∈{ξt​}t∈T​同样服从高斯分布 N ( μ t 1 → t n , Σ t 1 → t n ) mathcal N(mu_{t_1 to t_n},Sigma_{t_1 to t_n}) N(μt1​→tn​​,Σt1​→tn​​)。

贝叶斯线性回归

贝叶斯线性回归(Bayesian Linear Regression)本质上是利用贝叶斯方法处理线性回归任务。不同于频率派的点估计(Point Estimation),贝叶斯派将模型参数 W mathcal W W视作随机变量,它针对线性回归问题主要分为两个步骤:

  • 关于随机变量 W mathcal W W的推断任务(Inference):基于数据集合 D a t a Data Data,求解 W mathcal W W的后验概率。
    后验概率的高斯分布是基于’高斯分布的自共轭性质’。
    N ( W ∣ μ W , Σ W ) mathcal N(mathcal W mid mu_{mathcal W},Sigma_{mathcal W}) N(W∣μW​,ΣW​)这种表示描述的是‘关于 W mathcal W W作为后验的条件高斯分布’。
    P ( W ∣ D a t a ) ∼ N ( W ∣ μ W , Σ W ) mathcal P(mathcal W mid Data) sim mathcal N(mathcal W mid mu_{mathcal W},Sigma_{mathcal W}) P(W∣Data)∼N(W∣μW​,ΣW​)
    根据贝叶斯定理,将 P ( W ∣ D a t a ) mathcal P(mathcal W mid Data) P(W∣Data)表示为如下形式。其中似然 P ( Y ∣ W , X ) mathcal P(mathcal Y mid mathcal W,mathcal X) P(Y∣W,X)根据线性回归模型可表示为 包含0均值高斯噪声的线性关系;关于先验分布 P ( W ) mathcal P(mathcal W) P(W),将其假设为一个0均值的高斯分布;
    P ( W ∣ D a t a ) = P ( Y ∣ W , X ) ⋅ P ( W ) P ( Y ∣ X ) ∝ P ( Y ∣ W , X ) ⋅ P ( W ) = N ( W T X , σ 2 ) ⋅ N ( 0 , Σ p r i o r ) begin{aligned} mathcal P(mathcal W mid Data) & = frac{mathcal P(mathcal Y mid mathcal W,mathcal X) cdot mathcal P(mathcal W)}{mathcal P(mathcal Y mid mathcal X)} \ & propto mathcal P(mathcal Y mid mathcal W,mathcal X) cdot mathcal P(mathcal W) \ & = mathcal N(mathcal W^Tmathcal X,sigma^2) cdot mathcal N(0,Sigma_{prior}) end{aligned} P(W∣Data)​=P(Y∣X)P(Y∣W,X)⋅P(W)​∝P(Y∣W,X)⋅P(W)=N(WTX,σ2)⋅N(0,Σprior​)​
    对上式进行求解,可以得到后验概率 P ( W ∣ D a t a ) mathcal P(mathcal W mid Data) P(W∣Data)的高斯分布形式:
    贝叶斯线性回归推断任务推导过程传送门
    N ( μ W , Σ W ) → { μ W = A − 1 X T Y σ 2 Σ W = A − 1 A = X T X σ 2 + Σ p r i o r − 1 mathcal N(mu_{mathcal W},Sigma_{mathcal W}) to begin{cases} mu_{mathcal W} = frac{mathcal A^{-1} mathcal X^Tmathcal Y}{sigma^2} \ Sigma_{mathcal W} = mathcal A^{-1} \ mathcal A = frac{mathcal X^Tmathcal X}{sigma^2} + Sigma_{prior}^{-1} end{cases} N(μW​,ΣW​)→⎩ ⎨ ⎧​μW​=σ2A−1XTY​ΣW​=A−1A=σ2XTX​+Σprior−1​​

  • 基于推断得到的关于 W mathcal W W的后验概率,对给定样本 x ^ hat x x^的标签 y ^ hat y y^​进行预测(Prediction)。
    首先是无高斯噪声估计(Noise-Free):

    • 这里需要使用‘基于随机变量之间存在线性关系,高斯分布的表达’传送门
    • 公式中的 W mathcal W W表示已经通过 D a t a Data Data学习的后验概率。

    { f ( x ^ ) = W T x ^ = x ^ T W P [ f ( x ^ ) ∣ D a t a , x ^ ] ∼ N ( x ^ T μ W , x ^ T ⋅ Σ W ⋅ x ^ ) begin{cases} f(hat x) = mathcal W^T hat x = hat x^T mathcal W \ mathcal P[f(hat x) mid Data,hat x] sim mathcal N(hat x^T mu_{mathcal W},hat x^T cdot Sigma_{mathcal W} cdot hat x) end{cases} {f(x^)=WTx^=x^TWP[f(x^)∣Data,x^]∼N(x^TμW​,x^T⋅ΣW​⋅x^)​ 其次是高斯噪声估计(Noise):
    { y ^ = f ( x ^ ) + ϵ P ( y ^ ∣ D a t a , x ^ ) ∼ N ( x ^ T μ W , x ^ T ⋅ Σ W ⋅ x ^ + σ 2 ) begin{cases} hat y = f(hat x) + epsilon \ mathcal P(hat y mid Data,hat x) sim mathcal N(hat x^T mu_{mathcal W},hat x^T cdot Sigma_{mathcal W} cdot hat x + sigma^2) end{cases} {y^​=f(x^)+ϵP(y^​∣Data,x^)∼N(x^TμW​,x^T⋅ΣW​⋅x^+σ2)​

引子:贝叶斯方法求解非线性回归任务

假设此时的回归任务不是线性回归,而是非线性回归(Non-Linear),如何处理该问题:
在核方法与核函数介绍一节中针对样本无法线性可分 的问题,介绍了一种非线性转换(Non-Linear Transformation)函数: ϕ ( ⋅ ) phi(cdot) ϕ(⋅)。
该函数的作用是将当前样本 x ( i ) ∈ X x^{(i)} in mathcal X x(i)∈X的特征转化为高维特征:
x ( i ) → ϕ ( x ( i ) ) = z ( i ) x ( i ) ∈ R p ; z ( i ) ∈ R q ; q > p x^{(i)} to phi(x^{(i)}) = z^{(i)} quad x^{(i)} in mathbb R^p;z^{(i)} in mathbb R^q;q>p x(i)→ϕ(x(i))=z(i)x(i)∈Rp;z(i)∈Rq;q>p
根据Cover定理思想,就是找到一个合适的 ϕ phi ϕ,其目的是为了让 非线性 → to → 高维线性。
由于 ϕ phi ϕ函数从低维向高维映射的过程中,可能存在映射结果 z ( i ) z^{(i)} z(i)维度远远高于 x ( i ) x^{(i)} x(i),首先,计算这个高维映射 ϕ ( x ( i ) ) phi(x^{(i)}) ϕ(x(i))的计算代价就很高;其次,求解内积 [ ϕ ( x ( i ) ) ] T ϕ ( x ( j ) ) [phi(x^{(i)})]^Tphi(x^{(j)}) [ϕ(x(i))]Tϕ(x(j))过程中计算代价更高。,实际上,找非线性转换函数的本质是找合适的核函数(Kernal Function):
κ ( x ( i ) , x ( j ) ) = ⟨ ϕ ( x ( i ) ) , ϕ ( x ( j ) ) ⟩ = [ ϕ ( x ( i ) ) ] T ⋅ ϕ ( x ( j ) ) kappa(x^{(i)},x^{(j)}) = leftlanglephi(x^{(i)}),phi(x^{(j)})rightrangle = [phi(x^{(i)})]^T cdot phi(x^{(j)}) κ(x(i),x(j))=⟨ϕ(x(i)),ϕ(x(j))⟩=[ϕ(x(i))]T⋅ϕ(x(j))

需要知道:内积是从哪里出现的?
观察无高斯噪声估计(Noise-Free):
P [ f ( x ^ ) ∣ D a t a , x ^ ] ∼ N ( x ^ T μ W , x ^ T ⋅ Σ W ⋅ x ^ ) = N [ x ^ T ( A − 1 X T Y σ 2 ) , x ^ T ⋅ A − 1 ⋅ x ^ ] A − 1 = X T X σ 2 + Σ p r i o r − 1 begin{aligned} mathcal P[f(hat x) mid Data,hat x] & sim mathcal N(hat x^T mu_{mathcal W},hat x^T cdot Sigma_{mathcal W} cdot hat x) \ & = mathcal N left[hat x^T left(frac{mathcal A^{-1}mathcal X^Tmathcal Y}{sigma^2}right) ,hat x^T cdot mathcal A^{-1} cdot hat xright] quad mathcal A^{-1} = frac{mathcal X^Tmathcal X}{sigma^2} + Sigma_{prior}^{-1} end{aligned} P[f(x^)∣Data,x^]​∼N(x^TμW​,x^T⋅ΣW​⋅x^)=N[x^T(σ2A−1XTY​),x^T⋅A−1⋅x^]A−1=σ2XTX​+Σprior−1​​
随机变量集合 X = { x 1 , ⋯   , x p } mathcal X ={x_1,cdots,x_p} X={x1​,⋯,xp​}是一个非线性回归任务,根据上面描述,需要对样本 x ( i ) x^{(i)} x(i)进行非线性转换。假设关于 X N × p mathcal X_{N times p} XN×p​的非线性转换结果为:
ϕ ( X ) = [ ϕ ( x ( 1 ) ) , ϕ ( x ( 2 ) ) , ⋯   , ϕ ( x ( N ) ) ] N × q T phi(mathcal X) = left[phi(x^{(1)}),phi(x^{(2)}),cdots,phi(x^{(mathcal N)})right]^T_{N times q} ϕ(X)=[ϕ(x(1)),ϕ(x(2)),⋯,ϕ(x(N))]N×qT​
对应的无噪声模型表示为:
f ( x ) = [ ϕ ( x ) ] 1 × q T W q × 1 x ∈ X f (x) = left[phi(x)right]_{1 times q}^T mathcal W_{q times 1} quad x in mathcal X f(x)=[ϕ(x)]1×qT​Wq×1​x∈X
从而关于 x ^ hat x x^的预测任务表示为:
实际上就是将所有 x ^ , X hat x,mathcal X x^,X替换为 ϕ ( x ^ ) , ϕ ( X ) phi(hat x),phi(mathcal X) ϕ(x^),ϕ(X).
P [ f ( x ^ ) ∣ D a t a , x ^ ] ∼ N [ [ ϕ ( x ^ ) ] T ( A − 1 [ ϕ ( X ) ] T Y σ 2 ) , [ ϕ ( x ^ ) ] T ⋅ A − 1 ⋅ ϕ ( x ^ ) ] A = [ ϕ ( X ) ] T ϕ ( X ) σ 2 + Σ p r i o r − 1 mathcal P[f(hat x) mid Data,hat x] sim mathcal N left[[phi(hat x)]^T left(frac{mathcal A^{-1}[phi(mathcal X)]^Tmathcal Y}{sigma^2}right) ,[phi(hat x)]^T cdot mathcal A^{-1} cdot phi(hat x)right] quad mathcal A = frac{[phi(mathcal X)]^Tphi(mathcal X)}{sigma^2} + Sigma_{prior}^{-1} P[f(x^)∣Data,x^]∼N[[ϕ(x^)]T(σ2A−1[ϕ(X)]TY​),[ϕ(x^)]T⋅A−1⋅ϕ(x^)]A=σ2[ϕ(X)]Tϕ(X)​+Σprior−1​

至此,发现了:内积部分 [ ϕ ( X ) ] T ϕ ( X ) [phi(mathcal X)]^Tphi(mathcal X) [ϕ(X)]Tϕ(X)出现在矩阵 A mathcal A A 中。如何求解 A − 1 mathcal A^{-1} A−1?
最终的目的是将均值、方差 μ W , Σ W mu_{mathcal W},Sigma_{mathcal W} μW​,ΣW​写成关于‘核函数’ κ ( ⋅ , ⋅ ) kappa(cdot,cdot) κ(⋅,⋅)的方式,而 μ W , Σ W mu_{mathcal W},Sigma_{mathcal W} μW​,ΣW​中均是以 A − 1 mathcal A^{-1} A−1出现的。
这里引入一个关于求解矩阵逆 的定理: Woodbury Formula text{Woodbury Formula} Woodbury Formula。
仅需要了解如何使用即可。
( A + U C V ) − 1 = A − 1 − A − 1 U ( C − 1 + V A − 1 U ) − 1 V A − 1 (mathcal A + mathcal U mathcal C mathcal V)^{-1} = mathcal A^{-1} - mathcal A^{-1} mathcal U (mathcal C^{-1} + mathcal V mathcal A^{-1}mathcal U)^{-1} mathcal Vmathcal A^{-1} (A+UCV)−1=A−1−A−1U(C−1+VA−1U)−1VA−1

  • 观察 A = [ [ ϕ ( X ) ] T ϕ ( X ) σ 2 ] q × q + [ Σ p r i o r − 1 ] q × q mathcal A = left[frac{[phi(mathcal X)]^Tphi(mathcal X)}{sigma^2}right]_{q times q} + left[Sigma_{prior}^{-1}right]_{q times q} A=[σ2[ϕ(X)]Tϕ(X)​]q×q​+[Σprior−1​]q×q​:
    A mathcal A A自身是 q × q q times q q×q的矩阵。下面的步骤是为了直接凑均值项 A − 1 X Y σ 2 frac{mathcal A^{-1}mathcal X mathcal Y}{sigma^2} σ2A−1XY​.

均值表示的推导过程

  • 首先,等式左侧 A mathcal A A右乘一个 Σ p r i o r Sigma_{prior} Σprior​:
    其中, I mathcal I I表示单位矩阵; q × q q times q q×q
    A Σ p r i o r = [ ϕ ( X ) ] T ϕ ( X ) σ 2 Σ p r i o r + Σ p r i o r − 1 Σ p r i o r = [ ϕ ( X ) ] T ϕ ( X ) σ 2 Σ p r i o r + I q × q begin{aligned} mathcal A Sigma_{prior} & = frac{left[phi(mathcal X)right]^T phi(mathcal X)}{sigma^2}Sigma_{prior} + Sigma_{prior}^{-1}Sigma_{prior} \ & = frac{left[phi(mathcal X)right]^T phi(mathcal X)}{sigma^2}Sigma_{prior} + mathcal I_{q times q} end{aligned} AΣprior​​=σ2[ϕ(X)]Tϕ(X)​Σprior​+Σprior−1​Σprior​=σ2[ϕ(X)]Tϕ(X)​Σprior​+Iq×q​​
  • 在上步基础上,继续右乘一个 [ ϕ ( X ) ] T [phi(mathcal X)]^T [ϕ(X)]T:
    提出一个公因式 [ ϕ ( X ) ] T σ 2 frac{[phi(mathcal X)]^T}{sigma^2} σ2[ϕ(X)]T​,将两项合并,将 ϕ ( X ) Σ p r i o r [ ϕ ( X ) ] T phi(mathcal X)Sigma_{prior} [phi(mathcal X)]^T ϕ(X)Σprior​[ϕ(X)]T用核函数 K ( X , X ) mathcal K(mathcal X,mathcal X) K(X,X)这个记号进行表示。
    A Σ p r i o r [ ϕ ( X ) ] T = [ ϕ ( X ) ] T ϕ ( X ) Σ p r i o r [ ϕ ( X ) ] T σ 2 + [ ϕ ( X ) ] T = [ ϕ ( X ) ] T σ 2 { ϕ ( X ) Σ p r i o r [ ϕ ( X ) ] T + σ 2 I } = [ ϕ ( X ) ] T σ 2 [ K ( X , X ) + σ 2 I ] begin{aligned} mathcal A Sigma_{prior} [phi(mathcal X)]^T & = frac{left[phi(mathcal X)right]^T phi(mathcal X) Sigma_{prior}[phi(mathcal X)]^T}{sigma^2} + [phi(mathcal X)]^T \ & = frac{[phi(mathcal X)]^T}{sigma^2} left{phi(mathcal X) Sigma_{prior}[phi(mathcal X)]^T + sigma^2 mathcal Iright} \ & = frac{[phi(mathcal X)]^T}{sigma^2} left[mathcal K (mathcal X,mathcal X) + sigma^2 mathcal Iright] end{aligned} AΣprior​[ϕ(X)]T​=σ2[ϕ(X)]Tϕ(X)Σprior​[ϕ(X)]T​+[ϕ(X)]T=σ2[ϕ(X)]T​{ϕ(X)Σprior​[ϕ(X)]T+σ2I}=σ2[ϕ(X)]T​[K(X,X)+σ2I]​
  • 在上步基础上,左乘一个 A − 1 mathcal A^{-1} A−1:
    此时,等式左侧变成了 σ p r i o r [ ϕ ( X ) ] T sigma_{prior}[phi(mathcal X)]^T σprior​[ϕ(X)]T;
    Σ p r i o r [ ϕ ( X ) ] T = A − 1 [ ϕ ( X ) ] T σ 2 [ K ( X , X ) + σ 2 I ] begin{aligned} Sigma_{prior} [phi(mathcal X)]^T = frac{mathcal A^{-1} [phi(mathcal X)]^T}{sigma^2}left[mathcal K (mathcal X,mathcal X) + sigma^2 mathcal Iright] end{aligned} Σprior​[ϕ(X)]T=σ2A−1[ϕ(X)]T​[K(X,X)+σ2I]​
    从而有:
    相当于等式两边同乘 [ K ( X , X ) + σ 2 I ] − 1 [mathcal K(mathcal X,mathcal X) + sigma^2 mathcal I]^{-1} [K(X,X)+σ2I]−1
    A − 1 [ ϕ ( X ) ] T σ 2 = Σ p r i o r [ ϕ ( X ) ] T [ K ( X , X ) + σ 2 I ] − 1 frac{mathcal A^{-1} [phi(mathcal X)]^T}{sigma^2} = Sigma_{prior} [phi(mathcal X)]^T [mathcal K(mathcal X,mathcal X) + sigma^2 mathcal I]^{-1} σ2A−1[ϕ(X)]T​=Σprior​[ϕ(X)]T[K(X,X)+σ2I]−1

至此,均值部分相当于上式基础上,左乘一个 [ ϕ ( x ^ ) ] T [phi(hat x)]^T [ϕ(x^)]T,再右乘一个 Y mathcal Y Y:
这里面已知项有: Σ p r i o r Sigma_{prior} Σprior​是先验分布 P ( W ) mathcal P(mathcal W) P(W)的协方差矩阵; σ 2 sigma^2 σ2是回归模型的高斯噪声; K ( X , X ) mathcal K(mathcal X,mathcal X) K(X,X)是 ϕ ( X ) Σ p r i o r [ ϕ ( X ) ] T phi(mathcal X)Sigma_{prior} [phi(mathcal X)]^T ϕ(X)Σprior​[ϕ(X)]T的表示;
μ x ^ = [ ϕ ( x ) ] T ⋅ μ W = [ ϕ ( x ) ] T [ A − 1 [ ϕ ( X ) ] T σ 2 ] ⋅ Y = [ ϕ ( x ) ] T Σ p r i o r [ ϕ ( X ) ] T [ K ( X , X ) + σ 2 I ] − 1 Y begin{aligned} mu_{hat x} & = [phi(x)]^T cdot mu_{mathcal W} \ & = [phi(x)]^T left[frac{mathcal A^{-1}[phi(mathcal X)]^T}{sigma^2}right] cdot mathcal Y \ & = [phi(x)]^T Sigma_{prior} [phi(mathcal X)]^T [mathcal K(mathcal X,mathcal X) + sigma^2 mathcal I]^{-1} mathcal Y end{aligned} μx^​​=[ϕ(x)]T⋅μW​=[ϕ(x)]T[σ2A−1[ϕ(X)]T​]⋅Y=[ϕ(x)]TΣprior​[ϕ(X)]T[K(X,X)+σ2I]−1Y​
小结:实际上上述的均值求解仅是将 A mathcal A A带入到均值表达式中的求解过程,并没有使用 Woodbury Formula text{Woodbury Formula} Woodbury Formula定理。

方差表示的推导过程

继续求解高维转换后的方差表示。方差部分表示如下:
[ ϕ ( x ^ ) ] T ⋅ A − 1 ⋅ ϕ ( x ^ ) A = [ ϕ ( X ) ] T ϕ ( X ) σ 2 + Σ p r i o r − 1 [phi(hat x)]^T cdot mathcal A^{-1} cdot phi(hat x) quad mathcal A =frac{[phi(mathcal X)]^Tphi(mathcal X)}{sigma^2} + Sigma_{prior}^{-1} [ϕ(x^)]T⋅A−1⋅ϕ(x^)A=σ2[ϕ(X)]Tϕ(X)​+Σprior−1​
这里需要使用 Woodbury Formula text{Woodbury Formula} Woodbury Formula对 A − 1 mathcal A^{-1} A−1进行求解,或者使用上述拼凑的方式求解:
就是套公式~这里就不写过程了~
A − 1 = ( Σ p r i o r − 1 + 1 σ 2 [ ϕ ( X ) ] T ϕ ( X ) ) − 1 = Σ p r i o r − Σ p r i o r [ ϕ ( X ) ] T [ K ( X , X ) + σ 2 I ] − 1 ϕ ( X ) Σ p r i o r begin{aligned} mathcal A^{-1} & = left(Sigma_{prior}^{-1} + frac{1}{sigma^2}[phi(mathcal X)]^Tphi(mathcal X)right)^{-1} \ & = Sigma_{prior} - Sigma_{prior} [phi(mathcal X)]^T left[mathcal K(mathcal X,mathcal X) + sigma^2 mathcal Iright]^{-1} phi(mathcal X) Sigma_{prior} end{aligned} A−1​=(Σprior−1​+σ21​[ϕ(X)]Tϕ(X))−1=Σprior​−Σprior​[ϕ(X)]T[K(X,X)+σ2I]−1ϕ(X)Σprior​​

最终,经过非线性转换后的关于样本 x ^ hat x x^的后验分布表示为:
注意:这个是‘无高斯噪声’(Noise-Free)的分布。
P [ f ( x ^ ) ∣ D a t a , x ^ ] ∼ N [ [ ϕ ( x ^ ) ] T ( A − 1 [ ϕ ( X ) ] T Y σ 2 ) , [ ϕ ( x ^ ) ] T ⋅ A − 1 ⋅ ϕ ( x ^ ) ] = N ( μ x ^ , Σ x ^ ) { μ x ^ = [ ϕ ( x ) ] T Σ p r i o r [ ϕ ( X ) ] T [ K ( X , X ) + σ 2 I ] − 1 Σ x ^ = [ ϕ ( x ^ ) ] T ⋅ { Σ p r i o r − Σ p r i o r [ ϕ ( X ) ] T [ K ( X , X ) + σ 2 I ] − 1 ϕ ( X ) Σ p r i o r } ⋅ ϕ ( x ^ ) begin{aligned} mathcal P[f(hat x) mid Data,hat x] & sim mathcal N left[[phi(hat x)]^T left(frac{mathcal A^{-1}[phi(mathcal X)]^Tmathcal Y}{sigma^2}right) ,[phi(hat x)]^T cdot mathcal A^{-1} cdot phi(hat x)right] \ & = mathcal N(mu_{hat x},Sigma_{hat x}) begin{cases} mu_{hat x} = [phi(x)]^T Sigma_{prior} [phi(mathcal X)]^T [mathcal K(mathcal X,mathcal X) + sigma^2 mathcal I]^{-1} \ Sigma_{hat x} = [phi(hat x)]^T cdot left{Sigma_{prior} - Sigma_{prior} [phi(mathcal X)]^T left[mathcal K(mathcal X,mathcal X) + sigma^2 mathcal Iright]^{-1} phi(mathcal X) Sigma_{prior}right} cdot phi(hat x) end{cases} end{aligned} P[f(x^)∣Data,x^]​∼N[[ϕ(x^)]T(σ2A−1[ϕ(X)]TY​),[ϕ(x^)]T⋅A−1⋅ϕ(x^)]=N(μx^​,Σx^​){μx^​=[ϕ(x)]TΣprior​[ϕ(X)]T[K(X,X)+σ2I]−1Σx^​=[ϕ(x^)]T⋅{Σprior​−Σprior​[ϕ(X)]T[K(X,X)+σ2I]−1ϕ(X)Σprior​}⋅ϕ(x^)​​
从简化运算的角度,在从几何角度观察多维高斯分布一节中介绍关于协方差矩阵的定义,可以将其定义为一个对角矩阵,甚至是各向同性。

协方差函数(核函数)

回顾上述公式:
就是上述公式的展开式~
N [ [ ϕ ( x ^ ) ] T Σ p r i o r [ ϕ ( X ) ] T [ K ( X , X ) + σ 2 I ] − 1 Y ⏟ μ x ^ , [ ϕ ( x ^ ) ] T Σ p r i o r ϕ ( x ^ ) − [ ϕ ( x ^ ) ] T Σ p r i o r [ ϕ ( X ) ] T ( K ( X , X ) + σ 2 I ) − 1 ϕ ( X ) Σ p r i o r ϕ ( x ^ ) ⏟ Σ x ^ ] mathcal N left[underbrace{[phi(hat x)]^T Sigma_{prior}[phi(mathcal X)]^T [mathcal K(mathcal X,mathcal X) + sigma^2mathcal I]^{-1} mathcal Y}_{mu_{hat x}},underbrace{[phi(hat x)]^T Sigma_{prior} phi(hat x) - [phi(hat x)]^T Sigma_{prior}[phi(mathcal X)]^T(mathcal K(mathcal X,mathcal X) + sigma^2mathcal I)^{-1} phi(mathcal X) Sigma_{prior}phi(hat x)}_{Sigma_{hat x}} right] N ​μx^​ [ϕ(x^)]TΣprior​[ϕ(X)]T[K(X,X)+σ2I]−1Y​​,Σx^​ [ϕ(x^)]TΣprior​ϕ(x^)−[ϕ(x^)]TΣprior​[ϕ(X)]T(K(X,X)+σ2I)−1ϕ(X)Σprior​ϕ(x^)​​ ​
观察之前定义的符号 K ( X , X ) mathcal K(mathcal X,mathcal X) K(X,X):
K ( X , X ) = ϕ ( X ) ⋅ Σ p r i o r ⋅ [ ϕ ( X ) ] T mathcal K(mathcal X,mathcal X) = phi(mathcal X) cdot Sigma_{prior} cdot [phi(mathcal X)]^T K(X,X)=ϕ(X)⋅Σprior​⋅[ϕ(X)]T
这个格式在上述公式中比比皆是:
μ  part : { [ ϕ ( x ^ ) ] T Σ p r i o r [ ϕ ( X ) ] T K ( X , X ) Σ  part : { [ ϕ ( x ^ ) ] T Σ p r i o r ϕ ( x ^ ) [ ϕ ( x ^ ) ] T Σ p r i o r [ ϕ ( X ) ] T K ( X , X ) ϕ ( X ) Σ p r i o r ϕ ( x ^ ) ϕ ( X ) = [ ϕ ( x ( 1 ) ) , ϕ ( x ( 2 ) ) , ⋯   , ϕ ( x ( N ) ) ] N × q T begin{aligned} & mu text{ part}:begin{cases}[phi(hat x)]^T Sigma_{prior} [phi(mathcal X)]^T \ mathcal K(mathcal X,mathcal X) end{cases} \ & Sigma text{ part}:begin{cases} [phi(hat x)]^T Sigma_{prior} phi(hat x) \ [phi(hat x)]^T Sigma_{prior} [phi(mathcal X)]^T \ mathcal K(mathcal X,mathcal X) \ phi(mathcal X) Sigma_{prior} phi(hat x) end{cases} end{aligned} quad phi(mathcal X) = [phi(x^{(1)}),phi(x^{(2)}),cdots,phi(x^{(N)})]_{N times q}^T ​μ part:{[ϕ(x^)]TΣprior​[ϕ(X)]TK(X,X)​Σ part:⎩ ⎨ ⎧​[ϕ(x^)]TΣprior​ϕ(x^)[ϕ(x^)]TΣprior​[ϕ(X)]TK(X,X)ϕ(X)Σprior​ϕ(x^)​​ϕ(X)=[ϕ(x(1)),ϕ(x(2)),⋯,ϕ(x(N))]N×qT​

上述的所有格式,都可以用记号 K ( ⋅ , ⋅ ) mathcal K(cdot ,cdot) K(⋅,⋅)进行表示。这个记号函数 K ( ⋅ , ⋅ ) mathcal K(cdot ,cdot) K(⋅,⋅)到底是不是核函数?
这个高维转换函数 ϕ phi ϕ中有可能是一个向量:某一个原始 x p × 1 x_{p times 1} xp×1​;也有可能是一个'数据集合' X N × p mathcal X_{N times p} XN×p​
观察:由于先验分布的协方差矩阵 Σ p r i o r Sigma_{prior} Σprior​至少是半正定的,这里假设它的正定的,因而有:
Σ p r i o r = [ Σ p r i o r ] 2 = [ Σ p r i o r ] T Σ p r i o r Sigma_{prior} = left[sqrt{Sigma_{prior}}right]^2 = left[sqrt{Sigma_{prior}}right]^Tsqrt{Sigma_{prior}} Σprior​=[Σprior​ ​]2=[Σprior​ ​]TΣprior​ ​
因此, K ( x , x ′ ) mathcal K(x,x') K(x,x′)可表示为:
这里的 x , x ′ x,x' x,x′只是两个宏观的量,它可以表示上述任意一组格式。
K ( x , x ′ ) = [ ϕ ( x ) ] T Σ p r i o r ϕ ( x ′ ) = [ ϕ ( x ) ] T [ Σ p r i o r ] T Σ p r i o r   ϕ ( x ′ ) = [ Σ p r i o r   ϕ ( x ) ] T Σ p r i o r   ϕ ( x ′ ) begin{aligned} mathcal K(x,x') & = [phi(x)]^T Sigma_{prior} phi(x') \ & = [phi(x)]^T left[sqrt{Sigma_{prior}}right]^Tsqrt{Sigma_{prior}} text{ }phi(x') \ & = left[sqrt{Sigma_{prior}} text{ }phi(x)right]^Tsqrt{Sigma_{prior}} text{ }phi(x') end{aligned} K(x,x′)​=[ϕ(x)]TΣprior​ϕ(x′)=[ϕ(x)]T[Σprior​ ​]TΣprior​ ​ ϕ(x′)=[Σprior​ ​ ϕ(x)]TΣprior​ ​ ϕ(x′)​
这里令 ψ ( x ) = Σ p r i o r   ϕ ( x ) , ψ ( x ′ ) = Σ p r i o r   ϕ ( x ′ ) psi(x) = sqrt{Sigma_{prior}} text{ }phi(x),psi(x') = sqrt{Sigma_{prior}} text{ }phi(x') ψ(x)=Σprior​ ​ ϕ(x),ψ(x′)=Σprior​ ​ ϕ(x′),则有:
K ( x , x ′ ) = ⟨ ψ ( x ) , ψ ( x ′ ) ⟩ mathcal K(x,x') = leftlanglepsi(x),psi(x')rightrangle K(x,x′)=⟨ψ(x),ψ(x′)⟩
至此,可以使用核技巧(Kernal trick)将上述格式全部使用核函数 进行表示,从而跳过高维转换函数 ψ ( ⋅ ) psi(cdot) ψ(⋅)的复杂计算问题。

至此,将 贝叶斯线性回归 + 高维非线性转换 处理非线性回归问题 转换成基于核函数的贝叶斯线性回归问题(Kernal Bayesian Linear Regression,Kernal BLR)

高斯过程回归与线性贝叶斯回归的关系

实际上,贝叶斯线性回归(Bayesian Linear Regression)和核技巧相结合,构成了 高斯线性回归(Gaussian Linear Regression)。

  • 核技巧部分包括:非线性转换(Non-Linear Transformation) ϕ ( ⋅ ) phi(cdot) ϕ(⋅)部分以及内积(Inner Product) ⟨ ϕ ( ⋅ ) , ϕ ( ⋅ ) ⟩ leftlanglephi(cdot),phi(cdot)rightrangle ⟨ϕ(⋅),ϕ(⋅)⟩部分。
  • 这个关系就是‘权重空间视角’(Weight-Space)的结论。

高斯过程回归一般从两个视角进行描述:

  • (本节介绍的) 权重空间(Weight-Space)视角:即对模型参数 W mathcal W W在非线性转换后,由 p × 1 p times 1 p×1转换至 q × 1 q times 1 q×1的过程。
    关于先验概率分布 P ( W ) mathcal P(mathcal W) P(W)的分布也是随着‘非线性转换’维度的变化而变化。
    { f ( X ) = [ X ] N × p T W p × 1 Y = f ( X ) + ϵ ϵ ∼ N ( 0 , σ 2 ) ⇔ { f ( X ) = [ ϕ ( X ) ] N × q T W q × 1 Y = f ( X ) + ϵ ϵ ∼ N ( 0 , σ 2 ) begin{cases} f(mathcal X) = [mathcal X]_{N times p}^T mathcal W_{p times 1} \ mathcal Y = f(mathcal X) + epsilon quad epsilon sim mathcal N(0,sigma^2) end{cases} quad Leftrightarrow begin{cases} f(mathcal X) = [phi(mathcal X)]_{N times q}^T mathcal W_{q times 1} \ mathcal Y = f(mathcal X) + epsilon quad epsilon sim mathcal N(0,sigma^2) end{cases} {f(X)=[X]N×pT​Wp×1​Y=f(X)+ϵϵ∼N(0,σ2)​⇔{f(X)=[ϕ(X)]N×qT​Wq×1​Y=f(X)+ϵϵ∼N(0,σ2)​
    从贝叶斯线性回归的两个阶段思路也可以理解:先求 W mathcal W W的后验,再预测样本标签。

  • 函数空间(Function-Space)视角:相比于权重空间视角,它不关注模型参数 W mathcal W W,而是关注 f ( X ) f(mathcal X) f(X)空间本身。
    这两种视角没有区别,结果相同。

    它将 f ( X ) f(mathcal X) f(X)本身看做随机变量,并且 f ( X ) f(mathcal X) f(X)本身是一个高斯过程(Gaussian Process):
    f ( X ) ∼ G P [ m ( X ) , κ ( X , x ′ ) ] f(mathcal X) sim GP[m(mathcal X),kappa(mathcal X,x')] f(X)∼GP[m(X),κ(X,x′)]
    从高斯过程回归的角度,可以将其看做:贝叶斯线性回归 + 核函数的延伸。

下一节将介绍从函数空间视角观察高斯过程回归。

相关参考:
机器学习-高斯过程回归-权重空间角度

最后

以上就是结实画笔最近收集整理的关于机器学习笔记之高斯过程(二)高斯过程回归——权重空间角度引言的全部内容,更多相关机器学习笔记之高斯过程(二)高斯过程回归——权重空间角度引言内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(258)

评论列表共有 0 条评论

立即
投稿
返回
顶部