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

熱線電話:13121318867

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

關(guān)于神經(jīng)網(wǎng)絡(luò)過擬合的問題

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

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

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

Early Stopping就是在每次訓(xùn)練的epoch結(jié)束時(shí),將計(jì)算出的accuracy 跟上一次的進(jìn)行比較,如果accuracy 不再變化,那么停止訓(xùn)練。

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

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

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

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

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

就意味著沒有采用regularization來預(yù)防overfitting。

regularization 有 L1 regularization和L2 regularization。如果你想知道哪一個(gè)特征對最后的結(jié)果產(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(), // 加隨機(jī)數(shù)防止緩存 type: "get", dataType: "json", success: function (data) { $('#text').hide(); $('#wait').show(); // 調(diào)用 initGeetest 進(jìn)行初始化 // 參數(shù)1:配置參數(shù) // 參數(shù)2:回調(diào),回調(diào)的第一個(gè)參數(shù)驗(yàn)證碼對象,之后可以使用它調(diào)用相應(yīng)的接口 initGeetest({ // 以下 4 個(gè)配置參數(shù)為必須,不能缺少 gt: data.gt, challenge: data.challenge, offline: !data.success, // 表示用戶后臺(tái)檢測極驗(yàn)服務(wù)器是否宕機(jī) new_captcha: data.new_captcha, // 用于宕機(jī)時(shí)表示是新驗(yàn)證碼的宕機(jī) 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){ //倒計(jì)時(shí)完成 $(".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); }