How i can improve my Neural Network for printed lettters recognition?
1 view (last 30 days)
Show older comments
Hi all. I want to make a neural network for printed letters recognition. The type of NN is multilayer perceptron with 1 hidden layer. I used this dataset: https://archive.ics.uci.edu/ml/datasets/Letter+Recognition
I make my NN, but the testing result indicates that NN obtained 5% prediction accuracy. How I can make her more effective? I can't find other dataset for printed letters, to test with her. Of course I might have made a mistake somewhere and would be very grateful if you correct. This is code for my NN - 16 inputs and 26 targets ( I used 16000 simples for train and 4000 for test ).
clear all;
clc;
%reading from dataset
fid = fopen('letter-recognition.data', 'rt');
num_attrib = 16;
fmt = ['%s', repmat('%f', 1, num_attrib)];
datacell = textscan(fid, fmt, 'Delimiter', ',', 'CollectOutput', 1);
fclose(fid);
which_letter = char(datacell{1});
attribs = datacell{2};
target_codes = which_letter - 'A' + 1; %makes letters in numbers
%inputs
train_set = attribs(1:end-4000, :);
inputs = train_set.';% inputs 16x16000
%targets
train_targets = target_codes(1:end-4000);
letters = train_targets.';
targets = full(ind2vec(letters));% targets 16x16000 (eye)
%net
net = newff(minmax(inputs),[30 26], {'logsig','logsig'},'traingd');
net.inputweights{1,1}.initfcn = 'rands';
net.LW{2,1} = net.LW{2,1}*0.1;
net.b{2} = net.b{2}*0.1;
net.performFcn = 'mse';
net.trainParam.goal = 1e-2;
net.trainParam.show = 1;
net.trainparam.epochs = 800;
net.trainParam.lr = 0.1;
net.trainParam.max_fail = 5;
%divide data
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainRatio = 70/100; % 70 % for train
net.divideParam.valRatio = 15/100; % 15 % for validation
net.divideParam.testRatio = 15/100; %15 % for test
%train
[net,tr] = train(net,inputs,targets)
%prepare for sim
sim_attribs = attribs(end-3999:end, :);
sim_inputs = sim_attribs.';
sim_targets = target_codes(end-3999:end);
sim_letters = sim_targets.';
test_targets = full(ind2vec(sim_letters));
%sim
result = sim(net,sim_inputs);
%test NN
true = 0;
false = 0;
for index = 1:1:4000
[M,I] = max(result( : ,index));
[N,J] = max(test_targets( : ,index));
if(I == J)
true = true + 1;
else
false = false + 1;
end
end
p_true = (true / 4000)*100 % how % true
p_false = (false / 4000)*100 % how % false
0 Comments
Answers (0)
See Also
Categories
Find more on Pattern Recognition and Classification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!