深度学习代码注解(一)—— mnistdeepauto
生活随笔
收集整理的這篇文章主要介紹了
深度学习代码注解(一)—— mnistdeepauto
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
clear all
close all%% 1:參數設置
maxepoch=10; %In the Science paper we use maxepoch=50, but it works just fine.
numhid=1000; numpen=500; numpen2=250; numopen=30;%% 2:數據準備
fprintf(1,'Converting Raw files into Matlab format \n');
converter; fprintf(1,'Pretraining a deep autoencoder. \n');
fprintf(1,'The Science paper used 50 epochs. This uses %3i \n', maxepoch);makebatches;
% batchdata,第二個維度上的像素值,是 0-1 之間;
[numcases, numdims, numbatches]=size(batchdata);% [100*784*600],100*600 ==> 60000,也恰是訓練樣本的數目,也即batchdata存儲的全部是訓練樣本(不包括 targets); % numcases:行數(batch_size,塊內樣本的數目),樣本數目,numdims:維度數目,列數,% numbatches:塊的數目
%% 3:逐層訓練
% 第一層: numdims ? numhid(784 ? 1000)
fprintf(1,'Pretraining Layer 1 with RBM: %d-%d \n',numdims,numhid);
restart=1;
rbm;
hidrecbiases=hidbiases;
save mnistvh vishid hidrecbiases visbiases;% 第二層:numhid ? numen (1000 ==> 500)
fprintf(1,'\nPretraining Layer 2 with RBM: %d-%d \n',numhid,numpen);
batchdata = batchposhidprobs; % 第二層的輸入
numhid=numpen;
restart=1;
rbm;
hidpen=vishid; penrecbiases=hidbiases; hidgenbiases=visbiases;
save mnisthp hidpen penrecbiases hidgenbiases;% 第三層:numen ? numen(500 ? 250)
fprintf(1,'\nPretraining Layer 3 with RBM: %d-%d \n',numpen,numpen2);
batchdata=batchposhidprobs;
numhid=numpen2;
restart=1;
rbm;
hidpen2=vishid; penrecbiases2=hidbiases; hidgenbiases2=visbiases;
save mnisthp2 hidpen2 penrecbiases2 hidgenbiases2;% 第四層:numen2 ? numopen(250 ==> 30)
fprintf(1,'\nPretraining Layer 4 with RBM: %d-%d \n',numpen2,numopen);
batchdata=batchposhidprobs;
numhid=numopen;
restart=1;
rbmhidlinear;
hidtop=vishid; toprecbiases=hidbiases; topgenbiases=visbiases;
save mnistpo hidtop toprecbiases topgenbiases;backprop;
轉載于:https://www.cnblogs.com/mtcnn/p/9421767.html
總結
以上是生活随笔為你收集整理的深度学习代码注解(一)—— mnistdeepauto的全部內容,希望文章能夠幫你解決所遇到的問題。