neural nework validation accuracy calculation

I am currently training a CNN to do modulation classification using NN toolbox. The validation accuracy reported by matlab through the training progress window is approximated 50% at the end of training. But when I tested the accuracy myself using the trained network with the validation data set, it's only about 20% to 25%. This is calculated as (num of correct classification / overall number of tests).
How does matlab calculate the validation accuracy? Where can I find more information? Thanks.

답변 (1개)

Joy
Joy 2018년 2월 15일

0 개 추천

sure, here is the code
for snr = snr_str:2:snr_stop
ct_idx = ct_idx+1;
%loop through the data to find all signals with snr of current value
for k = 1:val_len
%check if the snr for this entry is correct
snr_str = string(squeeze(lbl(test_idx(k),2,:)).');
try
snr_i = str2num(snr_str);
catch
snr_i = str2num(char(snr_str));
end
if snr == snr_i
[YPre, scores] = classify(TO_net,valImages(:, :, 1, k));
if isequal(YPre, trainLabels(k))
%correct prediction
predictC_cnt = predictC_cnt+1;
else
predictW_cnt = predictW_cnt+1;
end
ct_idx_c = find(mods_str == string(YPre));
ct_idx_r = find(mods_str == string(trainLabels(k)));
confusionTbl(ct_idx, ct_idx_c, ct_idx_r) = confusionTbl(ct_idx, ct_idx_c, ct_idx_r)+1;
end
end
predictAcc_i = predictC_cnt/(predictC_cnt+predictW_cnt)*100;
predictAcc_t(ct_idx) = predictAcc_i;
%print overall accuracy for current snr
disp(['overall accuracy for snr = ', num2str(snr), ': ', num2str(predictAcc_i), ...
'% over ', num2str(predictC_cnt+predictW_cnt), ' tests']);
total_num_test = total_num_test + predictC_cnt+predictW_cnt;
predictC_cnt = 0;
predictW_cnt = 0;
end

댓글 수: 3

Joy
Joy 2018년 2월 20일
Just wondering why the CNN validation accuracy took a dive here on the last iteration? Please see the training progress plot attached.
I intentionally stopped the network from training early by giving a small number of MaxEpochs. This is because I suspected the network was overfitting. But I can't understand why the accuracy dropped so much on the last iteration.
Don Mathis
Don Mathis 2019년 2월 19일
Could you post your network layers and training options?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

질문:

Joy
2018년 2월 14일

댓글:

2019년 2월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by