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!