Deep learning: Dropout, DropConnect

Dropout

訓(xùn)練神經(jīng)網(wǎng)絡(luò)模型時(shí),如果訓(xùn)練樣本比較少,為了防止模型過擬合,可以使用Dropout來一定程度的減少過擬合。Dropout是Hinton 在2012年提出來的。


Dropout是指在模型訓(xùn)練時(shí)隨機(jī)的讓隱層節(jié)點(diǎn)的權(quán)重變成0,暫時(shí)認(rèn)為這些節(jié)點(diǎn)不是網(wǎng)絡(luò)結(jié)構(gòu)的一部分,但是會(huì)把它們的權(quán)重保留下來(不更新)上圖幫助理解。

我使用的是Matlab的Deeplearning 的工具包https://github.com/rasmusbergpalm/DeepLearnToolbox, 我只使用的是簡(jiǎn)單地單隱層的感知機(jī),數(shù)據(jù)是MNIST手寫數(shù)字識(shí)別,該數(shù)據(jù)一共有60000個(gè)訓(xùn)練樣本和10000個(gè)測(cè)試樣本。圖片大小是28 * 28,網(wǎng)絡(luò)結(jié)構(gòu)的層數(shù)是[784 512 10],100次迭代,minibatch大小是100,我做了在沒有dropout和有dropout的實(shí)驗(yàn)對(duì)比。dropout的值是0.5,即以0.5的概率隨機(jī)參數(shù)隱層節(jié)點(diǎn)。
代碼如下:

load mnist_uint8
train_x = double(train_x(1:60000,:)) / 255;
train_y = double(train_y(1:60000,:));
test_x = double(test_x(1:10000,:)) / 255;
test_y = double(test_y(1:10000,:));
[train_x ,mu, sigma] = zscore(train_x);
test_x = normalize(test_x, mu,sigma);

%% without dropout
rand(0);
nn = nnsetup([ 784 512 10]);
opts.numepochs = 100;
opts.batchsize = 100;
[nn, L] = nntrain(nn, train_x, train_y, opts);
[er, bad] = nntest(nn, test_x, test_y);
str = sprintf('testing error rate is : %f', er);
disp(str);

%% with dropout
rand(0);
nn = nnsetup([784 512 10]);
nn.dropoutFraction = 0.5;
opts.batchsize = 100;
opts.numepochs = 100;
nn = nntrain(nn, train_x, train_y, opts);
[er, bad] = nntest(nn, test_x, test_y);
str = sprintf('test error rate is : %f', er);
disp(str);

實(shí)驗(yàn)結(jié)果是:
test error rate is : 0.035200
With dropout, test error rate is : 0.031400

參考資料:

DropConnect

神經(jīng)網(wǎng)絡(luò)一般在大規(guī)模標(biāo)簽數(shù)據(jù)分類表現(xiàn)的很好,但是一幫需要更多的層數(shù)和更多的神經(jīng)元,單數(shù)如果沒有規(guī)范化的話,數(shù)百萬和數(shù)十億的參數(shù)很可能導(dǎo)致模型的過擬合。
現(xiàn)有的Regularization方法:

  • $l_1$ 或者 $l_2$ 懲罰
  • 貝葉斯的方法
  • 早停
  • 以上提到的Dropout方法[Hinton et al.2012]

DropConnect與Dropout不同的地方是在訓(xùn)練神經(jīng)網(wǎng)絡(luò)模型過程中,它不是隨機(jī)的將隱層節(jié)點(diǎn)的輸出變成0,而是將節(jié)點(diǎn)中的每個(gè)與其相連的輸入權(quán)值以1-p的概率變成0。(一個(gè)是輸出一個(gè)是輸入)


在MNITS數(shù)據(jù)集上的實(shí)驗(yàn)結(jié)果,分別是no-Drop,dropout和dropconnect的對(duì)比。

DropConnect的主頁有源碼可下載:DropConnect project page

參考資料

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容