-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMNIST_testing.m
More file actions
29 lines (28 loc) · 1.01 KB
/
MNIST_testing.m
File metadata and controls
29 lines (28 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
% Training
labels = loadMNISTLabels('/MATLAB Drive/BackPropagation/train-labels.idx1-ubyte');
labels = labels';
images = loadMNISTImages('/MATLAB Drive/BackPropagation/train-images.idx3-ubyte');
trainingTimes = 1;
learning_rate = 0.02;
istraining = true;
isMNIST = true;
obj_MNIST = BackPropLayer(1000,784,10,1000,learning_rate,"sigmoid",1,true, ...
trainingTimes,isMNIST);
obj_MNIST.train(images,labels);
% Testing
testing_labels = loadMNISTLabels('/MATLAB Drive/BackPropagation/t10k-labels.idx1-ubyte');
testing_labels = testing_labels';
obj_MNIST.acceptance_rate = 0.01;
testing_images = loadMNISTImages('/MATLAB Drive/BackPropagation/t10k-images.idx3-ubyte');
obj_MNIST.training = false;
correctCount = zeros(1,10);
totalCount = zeros(1,10);
for i = 1 : size(testing_images,2)
input = testing_images(:,i);
ex = testing_labels(:,i);
obj_MNIST.forward(input);
totalCount(ex+1) = totalCount(ex+1) + 1;
if (isequal(ex,obj_MNIST.prediction))
correctCount(ex+1) = correctCount(ex+1) + 1;
end
end