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
參考資料:
- 論文:《Improving neural networks by preventing co-adaptation of featuredetectors》
- https://github.com/rasmusbergpalm/DeepLearnToolbox
- Deep learning:四十一(Dropout簡(jiǎn)單理解)
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