UFLDL教程:Exercise:Vectorization
生活随笔
收集整理的這篇文章主要介紹了
UFLDL教程:Exercise:Vectorization
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
載入數據并顯示
Deep Learning and Unsupervised Feature Learning Tutorial Solutions
下載MINIST數據集及加載數據集的函數。MINIST數據集的介紹。
% Change the filenames if you've saved the files under different names % On some platforms, the files might be saved as % train-images.idx3-ubyte / train-labels.idx1-ubyte images = loadMNISTImages('train-images.idx3-ubyte'); labels = loadMNISTLabels('train-labels.idx1-ubyte');% We are using display_network from the autoencoder code display_network(images(:,1:100)); % Show the first 100 images disp(labels(1:10));修改train.m中的初始參數
visibleSize = 28*28; % number of input units 輸入層單元數 hiddenSize = 196; % number of hidden units隱藏層單元數 sparsityParam = 0.1; % desired average activation of the hidden units.稀疏值% (This was denoted by the Greek alphabet rho, which looks like a lower-case "p",% in the lecture notes). lambda = 3e-3; % weight decay parameter 權重衰減系數 beta = 3; % weight of sparsity penalty term稀疏值懲罰項的權重
修改訓練集,把step1里面的patches的產生改為
%% STEP 1: Implement sampleIMAGES 第1步:實現圖片采樣 %實現圖片采樣后,函數display_network從訓練集中隨機顯示200張 % After implementing sampleIMAGES, the display_network command should % display a random sample of 200 patches from the dataset %從10000張中隨機選擇200張顯示 % patches = sampleIMAGES; % figure % display_network(patches(:,randi(size(patches,2),200,1)),8) % title('sampleIMAGES') %%為產生一個200維的列向量,每一維的值為0~10000中的隨機數,說明是隨機取200個patch來顯示images = loadMNISTImages('train-images.idx3-ubyte'); labels = loadMNISTLabels('train-labels.idx1-ubyte');% We are using display_network from the autoencoder code figure display_network(images(:,1:100)); % Show the first 100 images title('first100images') figure disp(labels(1:10)); title('first100label')patches=zeros(visibleSize,10000);for i=1:10000patches(:,i)=reshape(images(:,i),visibleSize,1); end% patches = normalizeData(patches); % 在實現手寫字符識別時,是不需要對其做歸一化處理的 %要清楚的是,MINIST數據集本身就已經對數據進行了歸一化的處理% Obtain random parameters theta 初始化參數向量theta theta = initializeParameters(hiddenSize, visibleSize);
為了提高效率,可把train.m中的 STEP 3: Gradient Checking這步注釋掉,因為在本例中訓練集更大,梯度檢查會比較慢。
參考文獻
https://github.com/jiandanjinxin/matlab_code-ufldl-exercise-/tree/master/vectorization_exercise
深度學習入門教程UFLDL學習實驗筆記二:使用向量化對MNIST數據集做稀疏自編碼
Deep Learning 2_深度學習UFLDL教程:矢量化編程(斯坦福大學深度學習教程)
吳恩達 Andrew Ng 的公開課
總結
以上是生活随笔為你收集整理的UFLDL教程:Exercise:Vectorization的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 农行信用币有额度拒绝是怎么回事?申请被拒
- 下一篇: 信用卡什么时候会提额?三个技巧助你快速提