Accuracy between from the equation and the validation accuracy
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Sahil Jain
2021-10-18
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!