99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
首頁精彩閱讀關于神經(jīng)網(wǎng)絡中過擬合的問題
關于神經(jīng)網(wǎng)絡中過擬合的問題
2018-07-26
收藏

關于神經(jīng)網(wǎng)絡過擬合的問題

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

首先看一下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.
從以上兩段可以稍微總結一下,當你的模型過于復雜時,比如說輸入?yún)?shù)過多,你的模型就會出現(xiàn)過擬合問題,該模型雖然會在訓練集上表現(xiàn)出較好的預測結果,然而!在預測的時候呢?預測結果就會表現(xiàn)的很差。根據(jù)維基的定義以及我平時的一些實驗總結,當你observation 的noise 過多,輸入維度過大,都可能會導致overfitting。

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

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

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

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

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

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

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

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

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

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


數(shù)據(jù)分析咨詢請掃描二維碼

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

數(shù)據(jù)分析師資訊
更多

OK
客服在線
立即咨詢
客服在線
立即咨詢
') } function initGt() { var handler = function (captchaObj) { captchaObj.appendTo('#captcha'); captchaObj.onReady(function () { $("#wait").hide(); }).onSuccess(function(){ $('.getcheckcode').removeClass('dis'); $('.getcheckcode').trigger('click'); }); window.captchaObj = captchaObj; }; $('#captcha').show(); $.ajax({ url: "/login/gtstart?t=" + (new Date()).getTime(), // 加隨機數(shù)防止緩存 type: "get", dataType: "json", success: function (data) { $('#text').hide(); $('#wait').show(); // 調(diào)用 initGeetest 進行初始化 // 參數(shù)1:配置參數(shù) // 參數(shù)2:回調(diào),回調(diào)的第一個參數(shù)驗證碼對象,之后可以使用它調(diào)用相應的接口 initGeetest({ // 以下 4 個配置參數(shù)為必須,不能缺少 gt: data.gt, challenge: data.challenge, offline: !data.success, // 表示用戶后臺檢測極驗服務器是否宕機 new_captcha: data.new_captcha, // 用于宕機時表示是新驗證碼的宕機 product: "float", // 產(chǎn)品形式,包括:float,popup width: "280px", https: true // 更多配置參數(shù)說明請參見:http://docs.geetest.com/install/client/web-front/ }, handler); } }); } function codeCutdown() { if(_wait == 0){ //倒計時完成 $(".getcheckcode").removeClass('dis').html("重新獲取"); }else{ $(".getcheckcode").addClass('dis').html("重新獲取("+_wait+"s)"); _wait--; setTimeout(function () { codeCutdown(); },1000); } } function inputValidate(ele,telInput) { var oInput = ele; var inputVal = oInput.val(); var oType = ele.attr('data-type'); var oEtag = $('#etag').val(); var oErr = oInput.closest('.form_box').next('.err_txt'); var empTxt = '請輸入'+oInput.attr('placeholder')+'!'; var errTxt = '請輸入正確的'+oInput.attr('placeholder')+'!'; var pattern; if(inputVal==""){ if(!telInput){ errFun(oErr,empTxt); } return false; }else { switch (oType){ case 'login_mobile': pattern = /^1[3456789]\d{9}$/; if(inputVal.length==11) { $.ajax({ url: '/login/checkmobile', type: "post", dataType: "json", data: { mobile: inputVal, etag: oEtag, page_ur: window.location.href, page_referer: document.referrer }, success: function (data) { } }); } break; case 'login_yzm': pattern = /^\d{6}$/; break; } if(oType=='login_mobile'){ } if(!!validateFun(pattern,inputVal)){ errFun(oErr,'') if(telInput){ $('.getcheckcode').removeClass('dis'); } }else { if(!telInput) { errFun(oErr, errTxt); }else { $('.getcheckcode').addClass('dis'); } return false; } } return true; } function errFun(obj,msg) { obj.html(msg); if(msg==''){ $('.login_submit').removeClass('dis'); }else { $('.login_submit').addClass('dis'); } } function validateFun(pat,val) { return pat.test(val); }