Accuracy between from the equation and the validation accuracy
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
What is the different between the accuracy by using the Accuracy = sum ( diag (C)) / sum (C (:)) ×100 and the validation accuracy which run by the following coding:
[XTrain,YTrain] = digitTrain4DArrayData;
idx = randperm(size(XTrain,4),403);
XValidation = XTrain(:,:,:,idx);
XTrain(:,:,:,idx) = [];
YValidation = YTrain(idx);
YTrain(idx) = [];
layers = [
imageInputLayer([28 28 1])
convolution2dLayer(3,8,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,16,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,32,'Padding','same')
batchNormalizationLayer
reluLayer
fullyConnectedLayer(10)
softmaxLayer
classificationLayer];
options = trainingOptions('sgdm', ...
'MaxEpochs',8, ...
'ValidationData',{XValidation,YValidation}, ...
'ValidationFrequency',30, ...
'Verbose',false, ...
'Plots','training-progress');
NET = trainNetwork(XTrain,YTrain,layers,options);
0 Kommentare
Antworten (1)
Sahil Jain
am 18 Okt. 2021
Hi. You have not mentioned what "C" is. Assuming that "C" is the confusion matrix, accuracy values evaluated using both the approaches are equivalent and give the same result. Upon replacing the last line of your code with the following, you can observe that "accuracy1" and "accuracy2" both have the same value.
[NET, info] = trainNetwork(XTrain,YTrain,layers,options);
YPred = classify(NET, XValidation);
C = confusionmat(YValidation, YPred);
accuracy1 = sum (diag (C))/sum (C(:))*100;
accuracy2 = info.FinalValidationAccuracy;
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!