% Solve a Pattern Recognition Problem with a Neural Network % Script generated by NPRTOOL % % This script assumes these variables are defined: i=0; d=50 %for s=70:d:550 i=i+1; %s inputs = rot90(isoel); targets = rot90(yesno); % Create a Pattern Recognition Network hiddenLayerSize = 10; net = patternnet(hiddenLayerSize); % Set up Division of Data for Training, Validation, Testing net.divideParam.trainRatio = 70/100; net.divideParam.valRatio = 15/100; net.divideParam.testRatio = 15/100; for reps=1:20 % Train the Network [net2,tr] = train(net,inputs,targets); % Test the Network outputs = net2(inputs); errors = gsubtract(targets,outputs); performance = perform(net2,targets,outputs); % View the Network %view(net) %out=sim(net,inputs); %0er(reps)=sum(abs(out-targets)); tInd = tr.testInd; k=inputs(:,tInd); tstOutputs = net2(k); %tstPerform = perform(net,targets(tInd),tstOutputs) [c,cm,ind,per] = confusion(targets(tInd),tstOutputs); p_error_test(reps)=(1-(cm(1,1)+cm(2,2))/11)*100; % Plots % Uncomment these lines to enable various plots. %figure, plotperform(tr) %figure, plottrainstate(tr) %figure, plotconfusion(inputs,outputs) %figure, ploterrhist(errors) end avgerr(i)=mean(p_error_test); %end