In [1]:
clear ; close all; clc

In [2]:
%% Initialization

%% Setup the parameters you will use for this exercise
input_layer_size  = 400;  % 20x20 Input Images of Digits
hidden_layer_size = 25;   % 25 hidden units
num_labels = 10;          % 10 labels, from 1 to 10
                          % (note that we have mapped "0" to label 10)

In [3]:
% Load Training Data
fprintf('Loading and Visualizing Data ...\n')

load('./data/ex3data1.mat');
m = size(X, 1);

% Randomly select 100 data points to display
sel = randperm(size(X, 1));
sel = sel(1:100);

displayData(X(sel, :));


Loading and Visualizing Data ...

In [4]:
fprintf('\nLoading Saved Neural Network Parameters ...\n')

% Load the weights into variables Theta1 and Theta2
load('./data/ex3weights.mat');


Loading Saved Neural Network Parameters ...

In [5]:
pred = predict(Theta1, Theta2, X);
fprintf('\nTraining Set Accuracy: %f\n', mean(double(pred == y)) * 100);


Training Set Accuracy: 97.520000

In [6]:
%  Randomly permute examples
rp = randperm(m);

for i = 1:m
    % Display
    fprintf('\nDisplaying Example Image\n');
    displayData(X(rp(i), :));

    pred = predict(Theta1, Theta2, X(rp(i),:));
    fprintf('\nNeural Network Prediction: %d (digit %d)\n', pred, mod(pred, 10));
end


Displaying Example Image

Neural Network Prediction: 2 (digit 2)

Displaying Example Image

Neural Network Prediction: 1 (digit 1)

Displaying Example Image

Neural Network Prediction: 1 (digit 1)

Displaying Example Image

Neural Network Prediction: 7 (digit 7)

Displaying Example Image

Neural Network Prediction: 7 (digit 7)

Displaying Example Image

Neural Network Prediction: 4 (digit 4)

Displaying Example Image

Neural Network Prediction: 4 (digit 4)

Displaying Example Image

Neural Network Prediction: 7 (digit 7)

Displaying Example Image

Neural Network Prediction: 7 (digit 7)

Displaying Example Image

Neural Network Prediction: 6 (digit 6)

Displaying Example Image

Neural Network Prediction: 10 (digit 0)

Displaying Example Image

Neural Network Prediction: 5 (digit 5)

Displaying Example Image

Neural Network Prediction: 8 (digit 8)

Displaying Example Image

Neural Network Prediction: 8 (digit 8)

Displaying Example Image

Neural Network Prediction: 10 (digit 0)

Displaying Example Image

Neural Network Prediction: 9 (digit 9)

Displaying Example Image

Neural Network Prediction: 4 (digit 4)

Displaying Example Image

Neural Network Prediction: 3 (digit 3)

Displaying Example Image

Neural Network Prediction: 1 (digit 1)

Displaying Example Image

Neural Network Prediction: 3 (digit 3)

Displaying Example Image

Neural Network Prediction: 10 (digit 0)

Displaying Example Image

Neural Network Prediction: 5 (digit 5)

Displaying Example Image

Neural Network Prediction: 10 (digit 0)

Displaying Example Image

Neural Network Prediction: 3 (digit 3)

Displaying Example Image

Neural Network Prediction: 7 (digit 7)

Displaying Example Image

Neural Network Prediction: 8 (digit 8)

Displaying Example Image

Neural Network Prediction: 5 (digit 5)

Displaying Example Image

Neural Network Prediction: 5 (digit 5)

Displaying Example Image

Neural Network Prediction: 10 (digit 0)

Displaying Example Image

Neural Network Prediction: 10 (digit 0)

Displaying Example Image

Neural Network Prediction: 8 (digit 8)

Displaying Example Image

Neural Network Prediction: 7 (digit 7)

Displaying Example Image

Neural Network Prediction: 2 (digit 2)

Displaying Example Image

Neural Network Prediction: 2 (digit 2)

Displaying Example Image

Neural Network Prediction: 5 (digit 5)

Displaying Example Image

Neural Network Prediction: 10 (digit 0)

Displaying Example Image

Neural Network Prediction: 9 (digit 9)

Displaying Example Image

Neural Network Prediction: 10 (digit 0)

Displaying Example Image

Neural Network Prediction: 3 (digit 3)

Displaying Example Image

Neural Network Prediction: 9 (digit 9)

Displaying Example Image

Neural Network Prediction: 10 (digit 0)

Displaying Example Image

Neural Network Prediction: 8 (digit 8)

Displaying Example Image

Neural Network Prediction: 8 (digit 8)

Displaying Example Image

Neural Network Prediction: 3 (digit 3)

Displaying Example Image

Neural Network Prediction: 2 (digit 2)

Displaying Example Image

Neural Network Prediction: 10 (digit 0)

Displaying Example Image

Neural Network Prediction: 6 (digit 6)

Displaying Example Image

Neural Network Prediction: 6 (digit 6)

Displaying Example Image

Neural Network Prediction: 9 (digit 9)

Displaying Example Image

Neural Network Prediction: 10 (digit 0)

Displaying Example Image

Neural Network Prediction: 8 (digit 8)

Displaying Example Image

Neural Network Prediction: 2 (digit 2)

Displaying Example Image

Neural Network Prediction: 3 (digit 3)

Displaying Example Image

Neural Network Prediction: 2 (digit 2)

Displaying Example Image

Neural Network Prediction: 9 (digit 9)

Displaying Example Image

Neural Network Prediction: 8 (digit 8)

Displaying Example Image

Neural Network Prediction: 6 (digit 6)

Displaying Example Image

Neural Network Prediction: 2 (digit 2)

Displaying Example Image

Neural Network Prediction: 2 (digit 2)

Displaying Example Image

Neural Network Prediction: 7 (digit 7)

Displaying Example Image

Neural Network Prediction: 1 (digit 1)

Displaying Example Image

Neural Network Prediction: 6 (digit 6)

Displaying Example Image

Neural Network Prediction: 3 (digit 3)

Displaying Example Image

Neural Network Prediction: 4 (digit 4)

Displaying Example Image

Neural Network Prediction: 2 (digit 2)

Displaying Example Image

Neural Network Prediction: 10 (digit 0)

Displaying Example Image

Neural Network Prediction: 5 (digit 5)

Displaying Example Image

Gnuplot Produced by GNUPLOT 5.0 patchlevel 5 gnuplot_plot_1a ; 4 6 8 10 12 14 16 18 20 5 10 15 20

In [ ]: