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
참고 항목
카테고리
Help Center 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!