% GetDroppedDBN: get dropped dbn
%
% [DropedDBN OnInd] = GetDroppedDBN(dbn, DropOutRate, strbm)
%
%
%Output parameters:
% DropedDBN: the generated dropped Deep Belief Nets (DBN) model
% OnInd: indexes which are used (not dropped) nodes
%
%
%Input parameters:
% dbn: the Original Deep Belief Nets (DBN) model
% DropOutRate: 0 < DropOutRate < 1
% strbm (optional): started rbm layer to dropout (Default: 1)
%
%
%Reference:
%for details of the dropout
% Hinton et al, Improving neural networks by preventing co-adaptation of feature detectors, 2012.
%
%
%Version: 20130920
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Deep Neural Network: %
% %
% Copyright (C) 2013 Masayuki Tanaka. All rights reserved. %
% mtanaka@ctrl.titech.ac.jp %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [DropedDBN OnInd] = GetDroppedDBN(dbn, DropOutRate, strbm)
if( ~exist('strbm', 'var') || isempty(strbm) )
strbm = 1;
end
nrbm = numel(dbn.rbm); % 3
OnInd = GetOnInd(dbn, DropOutRate, strbm); % {16 x 32, 8 x 16, 4 x 8}
DropedDBN.type = dbn.type; % BBDBN
DropedDBN.rbm = cell(nrbm,1); % 3 x 1
for n=1:nrbm-1 % 1:2
DropedDBN.rbm{n}.type = dbn.rbm{n}.type; % BBRBM Bernoulli-Bernoulli Restricted Bolztmann Machine
DropedDBN.rbm{n}.W = dbn.rbm{n}.W(OnInd{n},OnInd{n+1}); % 512 x 128(= 16 x 32, 8 x 16), 128 x 32
DropedDBN.rbm{n}.b = dbn.rbm{n}.b(1,OnInd{n+1}); % 1 x 128 = 8 x 16, 1 x 32 = 4 x 8
DropedDBN.rbm{n}.c = dbn.rbm{n}.c(1,OnInd{n}); % 1 x 512 = 16 x 32
if( isequal(dbn.rbm{n}.type(1:2), 'GB') ) % BB
DropedDBN.rbm{n}.sig = dbn.rbm{n}.sig(1,OnInd{n});
end
end
n = nrbm; % 3
DropedDBN.rbm{n}.type = dbn.rbm{n}.type; % BBRBM Bernoulli-Bernoulli Restricted Bolztmann Machine
DropedDBN.rbm{n}.W = dbn.rbm{n}.W(OnInd{n},:); % 32 x 4 OnInd(4 x 8) dbn.rbm{n}.W(8 x 4)
DropedDBN.rbm{n}.b = dbn.rbm{n}.b; % 1 x 4
DropedDBN.rbm{n}.c = dbn.rbm{n}.c(1,OnInd{n}); % 1 x 32 dbn.rbm{n}.c(1 x 8)
if( isequal(dbn.rbm{n}.type(1:2), 'GB') )
DropedDBN.rbm{n}.sig = dbn.rbm{n}.sig(1,OnInd{n});
end
%{
debug> OnInd{n}(1,:)
ans =
Columns 1 through 19:
2 3 3 5 1 1 1 1 8 1 1 1 1 1 3 1 3 4 1
Columns 20 through 32:
1 4 2 4 2 1 4 2 2 2 5 2 3
debug> OnInd{n}(1:5,1:5)
ans =
2 3 3 5 1
12 6 5 6 3
13 7 8 10 4
13 9 13 11 4
15 9 13 11 5
debug> dbn.rbm{n}.W(OnInd{n}(1:5,1:5),OnInd{n+1}(1:3,1:3))
ans =
Columns 1 through 6:
-0.0518891 0.1645196 -0.3648530 -0.0518891 0.1645196 0.1203377
-0.0509273 -0.1455587 -0.0395848 -0.0509273 -0.1455587 -0.0887734
-0.1935831 0.0420215 -0.1951475 -0.1935831 0.0420215 0.1720987
-0.1935831 0.0420215 -0.1951475 -0.1935831 0.0420215 0.1720987
0.0756364 0.1362832 -0.3240471 0.0756364 0.1362832 -0.0595394
0.0107394 -0.1234916 0.1234910 0.0107394 -0.1234916 -0.1775845
-0.0695427 -0.0723231 0.0499915 -0.0695427 -0.0723231 0.0253774
-0.0848943 0.0936208 0.0172495 -0.0848943 0.0936208 -0.1848024
-0.0162922 0.1760467 -0.1882073 -0.0162922 0.1760467 0.0518954
-0.0162922 0.1760467 -0.1882073 -0.0162922 0.1760467 0.0518954
0.0107394 -0.1234916 0.1234910 0.0107394 -0.1234916 -0.1775845
-0.1144845 -0.3229443 0.0193068 -0.1144845 -0.3229443 -0.0304485
-0.0641209 0.0905255 0.3841493 -0.0641209 0.0905255 0.0108430
-0.1935831 0.0420215 -0.1951475 -0.1935831 0.0420215 0.1720987
-0.1935831 0.0420215 -0.1951475 -0.1935831 0.0420215 0.1720987
-0.1144845 -0.3229443 0.0193068 -0.1144845 -0.3229443 -0.0304485
-0.0695427 -0.0723231 0.0499915 -0.0695427 -0.0723231 0.0253774
0.0304704 0.0205339 0.0773431 0.0304704 0.0205339 -0.0291555
0.0077029 0.0241572 -0.0580945 0.0077029 0.0241572 -0.2857645
0.0077029 0.0241572 -0.0580945 0.0077029 0.0241572 -0.2857645
-0.0436215 0.1196918 -0.2066504 -0.0436215 0.1196918 0.1916691
0.0107394 -0.1234916 0.1234910 0.0107394 -0.1234916 -0.1775845
-0.0384129 -0.2294340 -0.1843899 -0.0384129 -0.2294340 -0.0182508
-0.0384129 -0.2294340 -0.1843899 -0.0384129 -0.2294340 -0.0182508
-0.1144845 -0.3229443 0.0193068 -0.1144845 -0.3229443 -0.0304485
Columns 7 through 9:
0.0265641 0.0265641 -0.0518891
0.0238093 0.0238093 -0.0509273
0.0737077 0.0737077 -0.1935831
0.0737077 0.0737077 -0.1935831
-0.1768547 -0.1768547 0.0756364
-0.0719310 -0.0719310 0.0107394
0.0053586 0.0053586 -0.0695427
-0.0316935 -0.0316935 -0.0848943
-0.1472840 -0.1472840 -0.0162922
-0.1472840 -0.1472840 -0.0162922
-0.0719310 -0.0719310 0.0107394
-0.0654309 -0.0654309 -0.1144845
-0.0759296 -0.0759296 -0.0641209
0.0737077 0.0737077 -0.1935831
0.0737077 0.0737077 -0.1935831
-0.0654309 -0.0654309 -0.1144845
0.0053586 0.0053586 -0.0695427
-0.0218777 -0.0218777 0.0304704
-0.1045122 -0.1045122 0.0077029
-0.1045122 -0.1045122 0.0077029
-0.0757484 -0.0757484 -0.0436215
-0.0719310 -0.0719310 0.0107394
0.1710117 0.1710117 -0.0384129
0.1710117 0.1710117 -0.0384129
-0.0654309 -0.0654309 -0.1144845
debug> ee
ee =
1 1 1
2 2 2
debug> ff
ff =
3 3 3
4 4 4
gg =
1 2 3 4 5 6 7 8 9 0
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
debug> gg(ee,ff)
ans =
3 4 3 4 3 4
13 14 13 14 13 14
3 4 3 4 3 4
13 14 13 14 13 14
3 4 3 4 3 4
13 14 13 14 13 14
debug> hh=[5,7;6,8]
hh =
5 7
6 8
debug> gg(ee,hh)
ans =
5 6 7 8
15 16 17 18
5 6 7 8
15 16 17 18
5 6 7 8
15 16 17 18
debug> exit
C:\Users\ars>
%}