Accuracy between from the equation and the validation accuracy

1 visualización (últimos 30 días)
TAN HOR YAN
TAN HOR YAN el 13 de Oct. de 2021
Respondida: Sahil Jain el 18 de Oct. de 2021
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);

Respuestas (1)

Sahil Jain
Sahil Jain el 18 de Oct. de 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;

Categorías

Más información sobre Deep Learning Toolbox en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by