Need help on neural network train test and validation accuracy

조회 수: 1 (최근 30일)
debasmita bhoumik
debasmita bhoumik 2016년 8월 28일
편집: Greg Heath 2016년 9월 1일
My data set have 420 images(24 features each). there are 160 for train. 20 for validation. 240 for testing. my problem is, after writing this code am getting 100% accuracy which is absurd. plz help me in this matter as am not sure if my code is correct or not.
% Solve a Pattern Recognition Problem with a Neural Network
load('ftrmat420.mat'); %420 x 24
load('class_test.mat'); %1 x 420
x=transpose(ftrmat420);
t=class_test;
inputs = x
targets = t
% Create a Pattern Recognition Network
hiddenLayerSize = 10;
net = patternnet(hiddenLayerSize);
% Set up Division of Data for Training, Validation, Testing
%net.divideParam.trainRatio = 30/100;
%net.divideParam.valRatio = 13/100;
%net.divideParam.testRatio = 57/100;
%[trainInd,valInd,testInd] = divideind(420,241:420,1:10,1:240);
net.divideFcn = 'divideind';
net.divideParam.trainInd = 261:420;
net.divideParam.valInd = 241:260;
net.divideParam.testInd = 1:240;
% Train the Network
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs)
performance = perform(net,targets,outputs)
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
figure, plotperform(tr)
figure, plottrainstate(tr)
figure, plotconfusion(targets,outputs)
[c,cm] = confusion(targets,outputs)
fprintf('Percentage Correct Classification : %f%%\n', 100*(1-c));
fprintf('Percentage Incorrect Classification : %f%%\n', 100*c);
figure, ploterrhist(errors)
trainTargets = targets .* tr.trainMask{1};
valTargets = targets .* tr.valMask{1};
testTargets = targets .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,outputs)
valPerformance = perform(net,valTargets,outputs)
testPerformance = perform(net,testTargets,outputs)

채택된 답변

Greg Heath
Greg Heath 2016년 9월 1일
편집: Greg Heath 2016년 9월 1일
Your data division fractions don't make sense at all.
160/20/240 ==> 0.38/0.05/0.57
You only have 160 training equations to estimate
(240+1)*10+(10+1)*1 = 2421 unknown weights
Your net is severely overfit.(i.e.,useless)
Stick with something close to the defaults 0.7/0.15/0.15
Hope this helps.
Thank you for formally accepting my answer
Greg

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by