熱線電話:13121318867

登錄
首頁精彩閱讀關于神經網絡中過擬合的問題
關于神經網絡中過擬合的問題
2018-07-26
收藏

關于神經網絡過擬合的問題

在訓練的時候你的模型是否會出現訓練時速度很慢?或者預測結果與訓練結果相差過大的現象?那我們可能就需要處理一下過擬合的問題了。

首先看一下overfitting維基百科上的一些信息:
Overfitting occurs when a model is excessively complex, such as having too many parameters relative to the number of observations. A model that has been overfit has poor predictive performance, as it overreacts to minor fluctuations in the training data.

In particular, a model is typically trained by maximizing its performance on some set of training data. However, its efficacy is determined not by its performance on the training data but by its ability to perform well on unseen data

The potential for overfitting depends not only on the number of parameters and data but also the conformability of the model structure with the data shape, and the magnitude of model error compared to the expected level of noise or error in the data.
從以上兩段可以稍微總結一下,當你的模型過于復雜時,比如說輸入參數過多,你的模型就會出現過擬合問題,該模型雖然會在訓練集上表現出較好的預測結果,然而!在預測的時候呢?預測結果就會表現的很差。根據維基的定義以及我平時的一些實驗總結,當你observation 的noise 過多,輸入維度過大,都可能會導致overfitting。

解決辦法就是我們可以啟用交叉驗證(cross-validation),正則化(regularization),Early Stopping,剪枝(pruning),Bayesian priors這幾種方法。

先說cross-validation:
cross-validation 的原理就是現在它的一個子集上做訓練,這個子集就是訓練集,再用驗證集測試所訓練出的模型,來評價模型的性能和指標,最后再用測試集來預測。

Early Stopping就是在每次訓練的epoch結束時,將計算出的accuracy 跟上一次的進行比較,如果accuracy 不再變化,那么停止訓練。

下面主要說下regularization在NN中的作用:

模型假設三層,輸入,隱藏,輸出。輸入層為2個神經元,輸出為2個,batchsize為10,下圖為當隱藏層神經元個數分別設置為3,6,20時,模型的情況:
 
注意看當隱藏神經元為20時,模型的狀況,每個紅色的點都被完美的歸類,沒錯,這在訓練時結果是很好,但是在測試集的表現呢?這就不一定了,誰能保證自己的訓練結每點噪聲呢?是不是?所以用這個模型去預測未知的,就可能造成預測結果很差,這就是NN的overfitting問題。

所以一般大部分情況,我們在調試模型時很多時候是在跟overfitting做斗爭。關于regularization方法。

簡單來說就是在目標函數上加一個λ

使之變成Error+λf(θ),λ用來懲罰那些權重很大的向量,稱之為正則系數吧!λ=0

就意味著沒有采用regularization來預防overfitting。

regularization 有 L1 regularization和L2 regularization。如果你想知道哪一個特征對最后的結果產生了比較大的影響,可以采用L1 regularization,如果你不那么在意對特征的分析,那就用L2 regularization吧。


數據分析咨詢請掃描二維碼

若不方便掃碼,搜微信號:CDAshujufenxi

數據分析師資訊
更多

OK
客服在線
立即咨詢
日韩人妻系列无码专区视频,先锋高清无码,无码免费视欧非,国精产品一区一区三区无码
客服在線
立即咨詢