5 神經網絡(PRML)

之前我們討論的模型是對於分類的迴歸模型,包含了線性組合的多個基礎函數。但是他的應用範圍有一定的限制。另外一個方法在於事先限定基礎函數的個數並且使得他可自適應的,也就是說使得他的參數值在訓練當中是可以發生變化的,其中最成功的模型是前向神經網絡(feed-forward network),也稱作多層認知模型(Multilayer perceptron)

1、前向網絡函數

在第三章和第四章中討論的迴歸線性分類模型的原型爲:

enter image description here

其中f()是一個用於分類非線性的激活函數,我們的目標在於將基本函數基於參數然後允許這些參數能夠被調整,我們首先構建M個這些線性值的組合:

enter image description here

得到這個aj值之後,緊接着我們得到:enter image description here,這個函數所作用的節點稱作隱藏節點(hidden units),而非線性函數h()通常使用sigmoid函數或者tanh函數,這些值 通常被線性組合得到:

enter image description here

enter image description here

其中:

enter image description here

因此:

enter image description here

因爲在神經網絡圖中存在一個直接的關係,我們可以使用一個普遍的函數關係,但是,這個函數關係僅限於前向神經網絡,而對於每一層節點,函數爲:

enter image description here

2、神經網絡訓練

對於前向網絡模型,我們對於訓練的一個目標在於減小誤差:

enter image description here

我們首先通過討論迴歸函數問題當我們討論一個目標變量t時:

enter image description here

因此對於多個數據我們可得:

enter image description here

我們對上式取負對數,可得:

enter image description here

因此,去掉後面的常數去掉,需要最小化的項爲:

enter image description here

當我們找到上式的最小值wML,可以得到:

enter image description here

enter image description here

因此,最小化總的式子的誤差值爲:

enter image description here

enter image description here

我們首先考慮從兩個類的分類情形:當t=1爲C1,t=0時爲C2,我們考慮從一個網絡模型,有一個單個輸出值,他的激活函數爲logistic sigmoid:

我們可以將y(x,w)解釋爲條件概率p(C1|x),而p(C2|x)爲1-p(x,w),我們可以將概率寫成如下的貝努利分佈格式:

enter image description here

因此,誤差函數可以取負對數:

enter image description here

同樣,對於有多個訓練樣本,我們可以得到:

enter image description here

因此誤差函數爲:

enter image description here

因此,當遇到多個類的分類情況(K個類)時,我們應當將使用如下條件:tk∈{0,1},輸出函數被解釋爲:y(x,w)=p(tk=1|x)。

enter image description here

而在第四章中我們討論得:

enter image description here

赫斯矩陣(Hessian Matrix)

我們顯示了錯誤回溯可以被用於錯誤函數的二次導數,由以下的式子顯示: enter image description here

赫斯矩陣在神經網絡計算中扮演這一個非常具有重要的位置:

1、一些非線性優化算法使用訓練神經網絡,神經網絡用於基於被赫斯矩陣控制的錯誤函數的二次屬性。

2、赫斯矩陣對前向神經網絡的再訓練生成一個快速的過程。

3、赫斯矩陣的逆置可以被用於識別最小神經網絡權值。

4、赫斯矩陣在貝葉斯神經網絡的拉普拉斯預測(Laplace approximation),他的逆置可以被用於決定訓練網絡的預測分佈,他的特徵值決定了超參數的值,他的行列式被用於估算模型的證據。

對角線估計

赫斯矩陣的對角線爲:

enter image description here

enter image description here

我們忽略非對角線的元素,可以獲得:

enter image description here

外部結果預測(Outer product approximation)

我們可以寫下赫斯矩陣爲如下形式:

enter image description here

通過忽略上式的第二項我們可以得到一個成爲Levenberg-Marquardt的預測或者outer product預測:

逆置赫斯矩陣:

首先我們寫出outer product 的預測值爲:

enter image description here

假設我們已經獲得L個數據點的逆置赫斯矩陣,通過分離enter image description here

因此我們考慮赫斯矩陣的逆置,我們可以得到:

enter image description here

enter image description here

最終導數

enter image description here

赫斯矩陣的精確預測

我們之前已經討論了很多對於赫斯矩陣的估計,我們這裏對赫斯矩陣做出精確的預測:首先我們預定義一下的標誌:

enter image description here

對於兩個都在第二層的:

enter image description here

兩個權值都在第一層中:

enter image description here

其中一個在第一層另一個在第二層中:

enter image description here

赫斯矩陣的快速乘法

在很多的赫斯矩陣的應用中,我們所感興趣的並不是赫斯矩陣本身,而是赫斯矩陣和某一個向量v的相乘的一個結果而enter image description here則是我們所希望得到的結果,爲了做到這一點我們首先標記:

enter image description here

對於這個標記,我們使用R{.}來標識enter image description here,因此enter image description here

我們還可以得到多個關係式:

enter image description here

我們還可以得到一下的式子:

enter image description here

enter image description here

神經網絡的正規化

我們在第一章中可以看到,爲了規避“過度擬合(overfitting)"所帶來的問題,我們可以在誤差函數後面加一個正規化項:

enter image description here

但是,對於上面的式子,也是存在一定的誤差的。就是因爲它和具體的範圍屬性不一致,爲了凸顯這個問題,我們考慮一個兩層模型,第一層隱含單元的激活函數爲如下的形式:

enter image description here

enter image description here

假設我們使用一個轉換模式:

enter image description here

然後我們可以做一下的轉化:

enter image description here

enter image description here

enter image description here

因此可以把輸出結果轉化爲:

enter image description here

因此,如果需要一個修正項能夠對這些轉化過程不發生變化,那麼,這樣的修正項可以被寫爲:

enter image description here

一旦發生上面的變量的變化,我們可以採取一下轉化:

enter image description here


赫斯矩陣(Hessian Matrix)

我們顯示了錯誤回溯可以被用於錯誤函數的二次導數,由以下的式子顯示: enter image description here

赫斯矩陣在神經網絡計算中扮演這一個非常具有重要的位置:

1、一些非線性優化算法使用訓練神經網絡,神經網絡用於基於被赫斯矩陣控制的錯誤函數的二次屬性。

2、赫斯矩陣對前向神經網絡的再訓練生成一個快速的過程。

3、赫斯矩陣的逆置可以被用於識別最小神經網絡權值。

4、赫斯矩陣在貝葉斯神經網絡的拉普拉斯預測(Laplace approximation),他的逆置可以被用於決定訓練網絡的預測分佈,他的特徵值決定了超參數的值,他的行列式被用於估算模型的證據。

對角線估計

赫斯矩陣的對角線爲:

enter image description here

enter image description here

我們忽略非對角線的元素,可以獲得:

enter image description here

外部結果預測(Outer product approximation)

我們可以寫下赫斯矩陣爲如下形式:

enter image description here

通過忽略上式的第二項我們可以得到一個成爲Levenberg-Marquardt的預測或者outer product預測:

逆置赫斯矩陣:

首先我們寫出outer product 的預測值爲:

enter image description here

假設我們已經獲得L個數據點的逆置赫斯矩陣,通過分離enter image description here

因此我們考慮赫斯矩陣的逆置,我們可以得到:

enter image description here

enter image description here

最終導數

enter image description here

赫斯矩陣的精確預測

我們之前已經討論了很多對於赫斯矩陣的估計,我們這裏對赫斯矩陣做出精確的預測:首先我們預定義一下的標誌:

enter image description here

對於兩個都在第二層的:

enter image description here

兩個權值都在第一層中:

enter image description here

其中一個在第一層另一個在第二層中:

enter image description here

赫斯矩陣的快速乘法

在很多的赫斯矩陣的應用中,我們所感興趣的並不是赫斯矩陣本身,而是赫斯矩陣和某一個向量v的相乘的一個結果而enter image description here則是我們所希望得到的結果,爲了做到這一點我們首先標記:

enter image description here

對於這個標記,我們使用R{.}來標識enter image description here,因此enter image description here

我們還可以得到多個關係式:

enter image description here

我們還可以得到一下的式子:

enter image description here

enter image description here

神經網絡的正規化

我們在第一章中可以看到,爲了規避“過度擬合(overfitting)"所帶來的問題,我們可以在誤差函數後面加一個正規化項:

enter image description here

但是,對於上面的式子,也是存在一定的誤差的。就是因爲它和具體的範圍屬性不一致,爲了凸顯這個問題,我們考慮一個兩層模型,第一層隱含單元的激活函數爲如下的形式:

enter image description here

enter image description here

假設我們使用一個轉換模式:

enter image description here

然後我們可以做一下的轉化:

enter image description here

enter image description here

enter image description here

因此可以把輸出結果轉化爲:

enter image description here

因此,如果需要一個修正項能夠對這些轉化過程不發生變化,那麼,這樣的修正項可以被寫爲:

enter image description here

一旦發生上面的變量的變化,我們可以採取一下轉化:

enter image description here


enter image description hereenter image description here對於絕大多數的模式識別的應用中我們對於結果的預測是不變的,無論對於輸入值採取的是怎樣複雜的變化,考慮對於一個二維圖像的分類(例如手寫體),某一個圖像應當被分類爲一個特定的類別而不論這個圖像具體存在於哪個位置。如果有一個足夠大的數量的訓練模版是有效的,那麼自適應模型(例如神經網絡模型)可以學習這個不變量,至少能夠大約推測出來。

這種方法也許不實用,但是如果訓練數量的個數是有限的,或者有一些不變量的存在,那麼我們可以尋找一個另外的一種方法來鼓勵自適應模型來凸顯需要的不變量,這些可以被分爲四大類:

1、訓練集通過訓練模版的副本進行放大,通過不變量的存在進行改變。

2、一個正規化項加到誤差函數中來補償由於輸入變化造成模型輸出值的改變,這個結果稱作tangent propagation切線繁殖

3、不變量被預置在預處理過程中,通過在需要改變的條件下提取不變量的特徵,任何隨後的迴歸或者分類系統使用這樣的特徵作爲輸入,將會包含這些不變值。

4、最後的一個方法就是將這些不變量屬性建立於神經網絡的結構中,一個獲得這個目的的方法就是通過使用局部接受域和共享權值。在卷積神經網絡中將會談論到。

Tangent propagation切線繁殖

我們可以通過正規化的手段來鼓勵模型對於輸入數據的變化,通過切線繁殖(Tangent Propagation)的手法達到目的,考慮一個特定的輸入向量xn的轉換的效果,考慮到這個變化是連續的,我們可以討論引入一個量ξ主宰了這個變化,因此切線向量爲:enter image description here

enter image description here

因此我們如果需要知道這個變量對於輸出結果的影響,我們需要用yk對ξ取導數:

enter image description here

通過添加一個修正項Ω給出一個新的誤差函數的形式:

enter image description here

enter image description here

在實際的應用中,τn可以被通過最終誤差方法(Finite Differences)來進行計算,通過減去原來的向量xn,然後再除以ξ即可得到。

訓練經過變化的數據

我們已經瞭解鼓勵一個模型的不變量的方法在於使用原先數據集發生改變過的版本來擴大訓練集數據,這裏我們引入一個方法和Tangent propagation非常接近的一個方法。

對於之前的那個例子我們瞭解到。如果沒有發生變化,誤差函數爲:

enter image description here

這裏我們考慮一個神經網絡的例子,只有一個輸出值,爲了保證標記值的清楚,我們這裏考慮這裏有無數個數據點的複製,其中ξ由p(ξ)來決定:

enter image description here

enter image description here

enter image description here

Ω值爲:

enter image description here

我們爲了更加對這個項進行簡化,我們可以採取以下的式子:

enter image description here

因此。對於第一項:

enter image description here

假設加入的噪聲點僅僅是添加了一個隨機噪音,即x->x+ξ,那麼修正項爲:

enter image description here

軟權值共享(Soft weight sharing)

一個減少網絡的複雜性的方法是通過限制權值在一些特定的羣組中,我們通過軟權值共享方法,其中強制限制權值方法被一個正則花方法取代,其中不同的組別的權值被鼓勵允許擁有相同的值大小。進一步,將不同的權值分配到不同的組別中,對於每一個組別的平均權值大小和這些值在組中的分佈情況是被認爲是一個學習過程。

我們回顧之前提到的一個簡單的權值衰減修正項,可以被視爲高斯先驗分佈的取負log,我們鼓勵這些權值形成多個不同的組別,而不是僅僅在一個組中間,通過考慮一個高斯分佈的組合實現,這些高斯分佈,包括混合的協參數,平均值,方差,可以被視爲可以進行調節的,並且是一個學習過程,因此我們有一個概率分佈形式爲:

enter image description here

enter image description here

我們可以得到一個正規化項函數爲如下的形式:

enter image description here

因此最終的誤差函數爲:

enter image description here

爲了最小化最終的誤差函數,我們必須要把誤差函數能夠對各種可進行調整的參數進行求導,我們首先需要把{πj}看作先驗概率然後引入一個相應的後驗概率:

enter image description here

enter image description here

誤差函數對高斯函數的中點可以被簡單地計算爲:

enter image description here

這裏有一個簡單而直接的解釋,由於它將μj推向權值的平均值

enter image description here

爲了實際的應用中我們引入一個新的參數ηj:

enter image description here

enter image description here

enter image description here

因此修正的誤差函數對ηj的求導爲:

enter image description here

因此,我們可以看到,πj逐漸被帶到後驗概率的平均值處。




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章