Neural Networks Warehouse
Artificial Intelligence Depot
"As knowledge increases, ignorance unfolds." -Kennedy
KNOWLEDGE MESSAGES SUBMIT SEARCH  
Preprocessing Input For Character Recognition
Help in designing effective input for back prop Neural Network
 
• Preprocessing Input For Character Recognition

I have alredy developed an implementation of Backprop trained neural network(MLP).

please guide me to any concrete form of preprocessing,
Inorder to get better performance in general for Hand written isolated character recognition,
Preprocessing help is welcomed either on input image, or on input vector.
input range is alredy normalized in [0,1].

please help,

regards,
Jigar Gosar

6 posts.
Monday 05 January, 21:36
Reply
• Pre-Processing for OCR

You will likely need to perform two types of pre-processing: 1. normalization and 2. feature extraction. By "normalization", I am referring to getting the bitmaps of the glyphs ("letters") into a standard position, scale, contrast, rotation, etc. within the field of view. "Feature extraction" means deriving measures from the raw data which are useful in making predictions. There are too many to list here, and some have been invented specifically for OCR- I suggest searching in any of the usual online engines: Teoma (www.teoma.com), Dogpile (www.dogpile.com), Yahoo! (www.yahoo.com), CiteSeer (www.citeseer.com), etc.

best of luck,
Will Dwinnell
http://will.dwinnell.com

249 posts.
Tuesday 06 January, 13:31
Reply
• specifics

please let me know one of the best feature extraction method,
which is commonly used, can be implemented without much hassle,
and gives optimal performance.

i have tried to search for it and am overvelhmed by the result,

please tell me 1 or 2, good fature extraction methods, for binary and grayscale images.

6 posts.
Thursday 08 January, 21:05
Reply
• OCR Feture Suggestions

Profiles are very easy to construct for binary or grayscale OCR. The vertical profile is simply the sums (or means if you prefer) of the columns. The horizontal profile is the sums (or means) of the rows. Other profiles can be constructed (diagonals are easy, too). Here's an example using sums:

5x7 Glyph Bitmap:
1 1 1 1 1
0 0 1 0 0
0 0 1 0 0
0 0 1 0 0
0 0 1 0 0
0 0 1 0 0
0 0 1 0 0

Vertical Profile:
1 1 7 1 1

Horizontal Profile:
5
1
1
1
1
1
1

I wrote out the profile vectors horizontally and vertically becuase that seemed most natural, but of course, that won't make any difference to the recognizer. Profiles are easy to create and understand, but notice their limitations. The following two glyphs are indistinguishable by vertical and horizontal profiles:

Character '2' Bitmap:
1 1 1 1 1
0 0 0 0 1
0 0 0 0 1
1 1 1 1 1
1 0 0 0 0
1 0 0 0 0
1 1 1 1 1

Character '5' Bitmap:
1 1 1 1 1
1 0 0 0 0
1 0 0 0 0
1 1 1 1 1
0 0 0 0 1
0 0 0 0 1
1 1 1 1 1

If the glyph bitmaps are large, it may help to reduce them by resizing. For instance, a 20x30 pixel glyph might be resize to 4x6, which throws away some information, but may be small enough to learn from.

More sophisticated features include signatures and invariant moments.

good luck,
Predictor
http://will.dwinnell.com

249 posts.
Friday 09 January, 08:48
Reply
• profiles

ok i can use both the profiles horizontal and vertical.
and i might the diogonal profiles too.

so total inputs will be 5+7+11=23

whereas 5x7=35.

well inputs r definately reduced.

my normalized image is a grayscale one with dimensions 10x14.
so inputs will be reduced from 140 to 10+14+23=47.

sounds good.

i am goning to try it.
ill post my experience with it.

but please let me know if there are some specifics that i might miss in using profiles.

regards,
Jigar.

6 posts.
Friday 09 January, 11:53
Reply
• Profiles

I suggest trying just the horizontal and vertical profiles first, the idea being to use as few inputs as will solve the problem. Heck, one or the other may do and in fact a variable-by-variable selection could reduce this further still. Anyway, a 10x14 (=140 variables) bitmap reduces to only 24 (=10+14) without the diagonal profiles. Keep in mind, if you do decide to try them, that there are two 45-degree diagonal profiles. One last caveat: the examples I gave used binary pixels, but things get a little muddier for grayscale.

One basic thing you might try is simple forward selection on the individual inputs. This means:

Build a model using only one input. Try each candidate input variable to see which works best by itself. Keep the best one.

Cycle through the remaining variables to see which works best with the already chosen input variable.

...and so on. Stop adding variables when model improvement stops significantly.

good luck,
Predictor
http://will.dwinnell.com

249 posts.
Friday 09 January, 12:59
Reply
• u r cool

THANKS A LOT,
for replying,

one more thing, what do u mean by,

"pixels, but things get a little muddier for grayscale"..

why and how???
and also what to do to filter the mud out.

regards,
Jigar

6 posts.
Friday 09 January, 13:19
Reply
• Muddy grayscale...

Profiles work on grayscale as well as binary data, but I think they trow away more information with grayscale, which has more information to begin with. I don't think this is crucial- profiles may work perfectly well for some applications.

By the way, if your images are originally grayscale (as from a scanner), and you are converting them to binary yourself, consider researching binarization or "thresholding" algorithms, which attempt to determine a good level at which to separate black and white.

-Predictor
http://will.dwinnell.com

249 posts.
Friday 09 January, 14:03
Reply
• Howzitgoin?

How is your OCR project coming along?

-Predictor
http://will.dwinnell.com

249 posts.
Friday 16 January, 10:33
Reply
• build problems

Hi,

my test(unit test) failed and i could not locate source of problem.

so i redesigned the whole application.....

aneways right now i am doing two things
1) writing an app to collect habd written samples of alphabets(i alredy had of digits, MNIST database;)
2) try ur profiling technique on digits.

but it will take time

cause i am preparing for my certification sjcp,
college is starting, and my girlfriend is in good mood now-a-days.

so u can see i am busy.

but as soon as i do something concrete i will let u know

regards,
Jigar

6 posts.
Friday 16 January, 15:33
Reply
• threshold

5x7 Glyph Bitmap:
1 1 1 1 1
0 1 0 0 0
0 1 0 0 0
0 1 0 0 0
0 1 0 0 0
0 1 0 0 0
0 1 0 0 0

For a bitmap like this? I still consider it a letter "T", but it has a different vertical profile as a standard "T". How can I set the threshold?

Thank you.

3 posts.
Monday 04 October, 23:18
Reply
• Translated ("Shifted") Glyphs in OCR

Translated ("shifted") glyphs can be handled a number of ways:

1. Center glyphs in the field of view, before attempting recognition.

2. Train the recongizer with randomly translated versions of example glyphs.

3. Use a representation which is (at least mostly) immune to translation. You are correct that the horizontally translated letter "T" changes the vertical projection, but it does not change the horizontal projection. Another example of a simple feature which would be largely unaffected by translation is the sum of all black pixels in the field of view.

-Will Dwinnell
http://will.dwinnell.com

249 posts.
Tuesday 21 December, 15:00
Reply
• threshold

5x7 Glyph Bitmap:
1 1 1 1 1
0 1 0 0 0
0 1 0 0 0
0 1 0 0 0
0 1 0 0 0
0 1 0 0 0
0 1 0 0 0

For a bitmap like this? I still consider it a letter "T", but it has a different vertical profile as a standard "T". How can I set the threshold?

Thank you.

3 posts.
Monday 04 October, 23:19
Reply
• Re:

I am going to assume that you're trying to have the neural network understand that your picture is a T just as the accurate picture of a T is.

To do that, it requires more than simple thresholding. It requires a patterned network connection that has what's known as a receptive field. The receptive field basically allows for noise. Instead of the neural net saying that only this line and this line can create a T, it will say that lines from here to here and from here to here can create a T. So, instead of this:

111111111
000010000
000010000
000010000
000010000
000010000

You would have this:

111111111
111111111
000111000
000111000
000111000
000111000

The 1's represent the area of the picture that will help the network determine whether the pattern is a T or not.

There is also another way to do this without using receptive fields. You could have the network learn the line patterns. You could have three neurons, one that determines if there is a horizontal line, another that determines if there is a vertical line, and another that determines if the top of the vertical line connects to the horizontal line in any place except for the very edges (which would look like an upside down L). Then have a neuron that takes all three outputs of those neurons and if all neurons fire, the fourth neuron fires saying that it is a T. So the network would look like this:

O O O
\ | /
\ | /
\|/
O

The bottom neuron is what says whether it is a T or not. The top row just looks for specific features (horizontal line, vertical line, connected lines). Have the threshold of the bottom neuron be so high that all three top neurons must fire in order for the bottom one to fire. So, for example, have the weights of the top 3 neurons be 1/3 or one-third and have the threshold of the bottom neuron be greater than 2/3 or two-thirds (so like .8 or .9 would be good).

The above network is a heavily scaled down version of how the brain really works. The mind also makes use of receptive fields at the same time. It does both, making its pattern processing more efficient. Not to mention that more than 4 neurons are involved in determining whether something is a T (especially when curvature of the lines becomes an issue). But the above network can do the job.

The Intellector

75 posts.
Tuesday 05 October, 20:08
Reply
• character recog.

hello I am doing a homework about character recognition. I will use vertical and horizontal profiles. I must use fuzzy logic in recognition. But I dont know what to fuzzy exactly. I decided to use histogram of the means of columns and rows and make the rules according to histogram values. Is it a good approach or are there better properties features for fuzzy recognition?
thanks

1 posts.
Monday 20 December, 18:33
Reply
• Character Recognition

The following on-line documents may give you some ideas:

http://www.freescale.com/files/microcontrollers/doc/app_note/AN1220_D.pdf
http://citeseer.ist.psu.edu/fonseca00using.html

Best of luck,
Will Dwinnell
http://will.dwinnell.com

249 posts.
Tuesday 21 December, 14:53
Reply
• Which training to use for Character Recognition ?

I need your help on the following codings.

This coding is used to recognize the characters (having 88 bits)( where the picture(11x8) converted to 1x88.

Which training is good for character recognition
(trainrp / traingdx or trainscg )

What are the advantages and disadvantages ?

How to set the goals and ohter training parameters ? I really dont have any idea.

Is my method of training OK ? Or, can you please suggest a better method.

Please help.

Thank you, Predictor

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
close all

[alphabet,targets] = SHLcharrec;
%[alphabet,targets] = SHLcharset1; % character library

[alphabet1,targets1] = SHLcharset1;
[alphabet2,targets2] = SHLcharset2;
[alphabet3,targets3] = SHLcharset3;
[alphabet4,targets4] = SHLcharset4;
[alphabet5,targets5] = SHLcharset5;
[alphabet6,targets6] = SHLcharset6;
[alphabet7,targets7] = SHLcharset7;
[alphabet8,targets8] = SHLcharset8;
[alphabet9,targets9] = SHLcharset9;
[alphabet10,targets10] = SHLcharset10;

[R,Q] = size(alphabet)
[S2,Q] = size(targets);

% pre process data
% ================

[alphabet_pp,meanA,stdA]=prestd(alphabet) ;

[alphabet1,mean1,std1]=prestd(alphabet1) ;
[alphabet2,mean2,std2]=prestd(alphabet2) ;
[alphabet3,mean3,std3]=prestd(alphabet3) ;
[alphabet4,mean4,std4]=prestd(alphabet4) ;
[alphabet5,mean5,std5]=prestd(alphabet5) ;
[alphabet6,mean6,std6]=prestd(alphabet6) ;
[alphabet7,mean7,std7]=prestd(alphabet7) ;
[alphabet8,mean8,std8]=prestd(alphabet8) ;
[alphabet9,mean9,std9]=prestd(alphabet9) ;
[alphabet10,mean10,std10]=prestd(alphabet10) ;


P = alphabet_pp; % 88 rows , 35 columns
T = targets; % 35 by 35 matrixs

% DEFINING THE NETWORK
% ====================

% The character recognition network will have 10 TANSIG
% neurons in its hidden layer.

%S1 = 10;
S1 = 25;
net = newff(minmax(P),[S1 S2],{'logsig' 'logsig'},'trainscg n');

net = init(net); % weight & bias initialization

net.IW{1,1} = 1/sqrt(R) * (2*rand(size(net.IW{1,1}))-1); % R = 88 !!!
net.b{1} = 1/sqrt(R) * (2*rand(size(net.b{1}))-1);

net.LW{2,1} = 1/sqrt(S1) * (2*rand(size(net.LW{2,1}))-1);
net.b{2} = 1/sqrt(S1) * (2*rand(size(net.b{2}))-1);

% TRAINING THE NETWORK WITHOUT NOISE ( IDEAL CASE )
% =================================================

net.performFcn = 'sse'; % Sum-Squared Error performance function

net.trainParam.goal = 0.3; % % Sum-squared error goal.
net.trainParam.show = 20; % Frequency of progress displays (in epochs).
net.trainParam.epochs = 500; % Maximum number of epochs to train.
net.trainParam.mc = 0.95; % Momentum constant.
net.trainParam.lr = 0.0001 ;

[net,tr] = train(net,P,T);

save NNforCharRec net
%save NNforCharRec

% TRAINING THE NETWORK WITH NOISE ( 3 sets )
% ===============================

% A copy of the network will now be made. This copy will
% be trained with noisy examples of letters of the alphabet.

netn = net;

netn.trainParam.goal = 1e1; % Mean-squared error goal.
netn.trainParam.epochs = 500; % Maximum number of epochs to train.

% The network will be trained on 11 sets of noisy data collected from the samples.

T = [targets targets1 targets2 targets3 targets4 targets5 targets6 targets7 targets8 targets9 targets10];

for pass = 1:11
fprintf('Pass = %.0f\n',pass);
P = [alphabet_pp, alphabet1, alphabet2, alphabet3, alphabet4, alphabet5, alphabet6, alphabet7, alphabet8, alphabet9, alphabet10];

% pre processing
PN = trastd(P,meanA,stdA);

[netn,tr] = train(netn,PN,T);
end

% save NNforCharRec netn
save NNforCharRec

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
One of the samples for training ( There are another 10 more sets similar to this.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [alphabet,targets] = SHLcharrec()
% SHAHUL Character recognition problem definition
%
% [ALHABET,TARGETS] = SHLcharrec()
% Returns:
% ALPHABET - 88x36 matrix of 8x11 bit maps for each letter.
% TARGETS - 36x36 target vectors, for both characters and numbers.

% Date : 7 Disember 2004, Time : 7.41 pm

letterA = [0 0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
1 1 1 0 0 1 1 1 ...
0 1 1 1 1 1 1 0 ...
0 0 1 1 1 1 0 0 ...
0 1 1 1 1 1 1 0 ...
1 1 1 0 0 1 1 1 ...
1 1 1 0 0 1 1 1 ...
0 1 1 1 1 1 1 0 ...
0 0 1 1 1 1 0 0 ]';


number9 = [ 0 0 1 1 1 1 0 0 ...
0 1 1 1 1 1 1 0 ...
1 1 0 0 0 1 1 1 ...
1 1 0 0 0 1 1 1 ...
1 1 0 0 0 1 1 1 ...
0 1 1 1 1 1 1 1 ...
0 0 1 1 1 1 1 1 ...
0 0 0 0 0 1 1 1 ...
1 1 1 0 0 1 1 1 ...
0 1 1 1 1 1 1 0 ...
0 0 1 1 1 1 0 0 ]';

numberZero = [0 0 1 1 1 1 0 0 ...
0 1 1 1 1 1 1 0 ...
1 1 1 0 0 1 1 1 ...
1 1 0 0 0 0 1 1 ...
1 1 0 0 0 0 1 1 ...
1 1 0 0 0 0 1 1 ...
1 1 0 0 0 0 1 1 ...
1 1 0 0 0 0 1 1 ...
1 1 1 0 0 1 1 1 ...
0 1 1 1 1 1 1 0 ...
0 0 1 1 1 1 0 0]';


alphabet = [letterA,letterB,letterC,letterD,letterE,letterF,letterG,letterH,...
letterI,letterJ,letterK,letterL,letterM,letterN,letterP,...
letterQ,letterR,letterS,letterT,letterU,letterV,letterW,letterX,...
letterY,letterZ,number1,number2,number3,number4,number5,number6,...
number7,number8,number9,numberZero];

targets = eye(35);

8 posts.
Sunday 13 February, 23:27
Reply
• Which training to use for Character Recognition ?

I need your help on the following codings.

This coding is used to recognize the characters (having 88 bits)( where the picture(11x8) converted to 1x88.

Which training is good for character recognition
(trainrp / traingdx or trainscg )

What are the advantages and disadvantages ?

How to set the goals and ohter training parameters ? I really dont have any idea.

Is my method of training OK ? Or, can you please suggest a better method.

Please help.

Thank you, Predictor

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
close all

[alphabet,targets] = SHLcharrec;
%[alphabet,targets] = SHLcharset1; % character library

[alphabet1,targets1] = SHLcharset1;
[alphabet2,targets2] = SHLcharset2;
[alphabet3,targets3] = SHLcharset3;
[alphabet4,targets4] = SHLcharset4;
[alphabet5,targets5] = SHLcharset5;
[alphabet6,targets6] = SHLcharset6;
[alphabet7,targets7] = SHLcharset7;
[alphabet8,targets8] = SHLcharset8;
[alphabet9,targets9] = SHLcharset9;
[alphabet10,targets10] = SHLcharset10;

[R,Q] = size(alphabet)
[S2,Q] = size(targets);

% pre process data
% ================

[alphabet_pp,meanA,stdA]=prestd(alphabet) ;

[alphabet1,mean1,std1]=prestd(alphabet1) ;
[alphabet2,mean2,std2]=prestd(alphabet2) ;
[alphabet3,mean3,std3]=prestd(alphabet3) ;
[alphabet4,mean4,std4]=prestd(alphabet4) ;
[alphabet5,mean5,std5]=prestd(alphabet5) ;
[alphabet6,mean6,std6]=prestd(alphabet6) ;
[alphabet7,mean7,std7]=prestd(alphabet7) ;
[alphabet8,mean8,std8]=prestd(alphabet8) ;
[alphabet9,mean9,std9]=prestd(alphabet9) ;
[alphabet10,mean10,std10]=prestd(alphabet10) ;


P = alphabet_pp; % 88 rows , 35 columns
T = targets; % 35 by 35 matrixs

% DEFINING THE NETWORK
% ====================

% The character recognition network will have 10 TANSIG
% neurons in its hidden layer.

%S1 = 10;
S1 = 25;
net = newff(minmax(P),[S1 S2],{'logsig' 'logsig'},'trainscg n');

net = init(net); % weight & bias initialization

net.IW{1,1} = 1/sqrt(R) * (2*rand(size(net.IW{1,1}))-1); % R = 88 !!!
net.b{1} = 1/sqrt(R) * (2*rand(size(net.b{1}))-1);

net.LW{2,1} = 1/sqrt(S1) * (2*rand(size(net.LW{2,1}))-1);
net.b{2} = 1/sqrt(S1) * (2*rand(size(net.b{2}))-1);

% TRAINING THE NETWORK WITHOUT NOISE ( IDEAL CASE )
% =================================================

net.performFcn = 'sse'; % Sum-Squared Error performance function

net.trainParam.goal = 0.3; % % Sum-squared error goal.
net.trainParam.show = 20; % Frequency of progress displays (in epochs).
net.trainParam.epochs = 500; % Maximum number of epochs to train.
net.trainParam.mc = 0.95; % Momentum constant.
net.trainParam.lr = 0.0001 ;

[net,tr] = train(net,P,T);

save NNforCharRec net
%save NNforCharRec

% TRAINING THE NETWORK WITH NOISE ( 3 sets )
% ===============================

% A copy of the network will now be made. This copy will
% be trained with noisy examples of letters of the alphabet.

netn = net;

netn.trainParam.goal = 1e1; % Mean-squared error goal.
netn.trainParam.epochs = 500; % Maximum number of epochs to train.

% The network will be trained on 11 sets of noisy data collected from the samples.

T = [targets targets1 targets2 targets3 targets4 targets5 targets6 targets7 targets8 targets9 targets10];

for pass = 1:11
fprintf('Pass = %.0f\n',pass);
P = [alphabet_pp, alphabet1, alphabet2, alphabet3, alphabet4, alphabet5, alphabet6, alphabet7, alphabet8, alphabet9, alphabet10];

% pre processing
PN = trastd(P,meanA,stdA);

[netn,tr] = train(netn,PN,T);
end

% save NNforCharRec netn
save NNforCharRec

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
One of the samples for training ( There are another 10 more sets similar to this.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [alphabet,targets] = SHLcharrec()
% SHAHUL Character recognition problem definition
%
% [ALHABET,TARGETS] = SHLcharrec()
% Returns:
% ALPHABET - 88x36 matrix of 8x11 bit maps for each letter.
% TARGETS - 36x36 target vectors, for both characters and numbers.

% Date : 7 Disember 2004, Time : 7.41 pm

letterA = [0 0 0 1 1 0 0 0 ...
0 0 0 1 1 0 0 0 ...
0 0 1 1 1 1 0 0 ...
0 0 1 1 1 1 0 0 ...
0 0 1 0 0 1 0 0 ...
0 0 1 0 0 1 0 0 ...
0 1 1 1 1 1 1 0 ...
0 1 1 1 1 1 1 0 ...
0 1 1 1 1 1 1 0 ...
1 1 0 0 0 0 1 1 ...
1 1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1 1 0 ...
1 1 0 0 0 1 1 1 ...
1 1 0 0 0 1 1 1 ...
1 1 0 0 0 1 1 1 ...
0 1 1 1 1 1 1 1 ...
0 0 1 1 1 1 1 1 ...
0 0 0 0 0 1 1 1 ...
1 1 1 0 0 1 1 1 ...
0 1 1 1 1 1 1 0 ...
0 0 1 1 1 1 0 0 ]';

numberZero = [0 0 1 1 1 1 0 0 ...
0 1 1 1 1 1 1 0 ...
1 1 1 0 0 1 1 1 ...
1 1 0 0 0 0 1 1 ...
1 1 0 0 0 0 1 1 ...
1 1 0 0 0 0 1 1 ...
1 1 0 0 0 0 1 1 ...
1 1 0 0 0 0 1 1 ...
1 1 1 0 0 1 1 1 ...
0 1 1 1 1 1 1 0 ...
0 0 1 1 1 1 0 0]';


alphabet = [letterA,letterB,letterC,letterD,letterE,letterF,letterG,letterH,...
letterI,letterJ,letterK,letterL,letterM,letterN,letterP,...
letterQ,letterR,letterS,letterT,letterU,letterV,letterW,letterX,...
letterY,letterZ,number1,number2,number3,number4,number5,number6,...
number7,number8,number9,numberZero];

targets = eye(35);

8 posts.
Sunday 13 February, 23:28
Reply
• Need help for Hindi OCR

Hi

I am making a project for recognizing Hindi characters I have decided to do it with Matlab.
So It will be a great help if any body can provide me source code in Matlab. I need it urgently.
so please help me.

Thanks
amita

1 posts.
Wednesday 22 June, 01:22
Reply
• Which training to use for Character Recognition ?

I need your help on the following codings.

This coding is used to recognize the characters (having 88 bits)( where the picture(11x8) converted to 1x88. (Is this size too big ?)
(Even after resizing, the letter G get connected, becomes number 6 !).

Which training is good for character recognition
(trainrp / traingdx or trainscg or ant other)

What are the advantages and disadvantages ?

How to set the goals and other training parameters ? I really dont have any idea.It alway states, Goal not met.

Which transfer function is better, for both input, hidden and output layer ? ( in this coding, one of the 35 output will be '1' and others will be '0', giving the 'character' it represents.

Is my method of training OK ? Or, can you please suggest a better method.

Please help.

Thank you, Predictor

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
close all

[alphabet,targets] = SHLcharrec; % character library

[alphabet1,targets1] = SHLcharset1; % 10 sets of samples.
[alphabet2,targets2] = SHLcharset2;
[alphabet3,targets3] = SHLcharset3;
[alphabet4,targets4] = SHLcharset4;
[alphabet5,targets5] = SHLcharset5;
[alphabet6,targets6] = SHLcharset6;
[alphabet7,targets7] = SHLcharset7;
[alphabet8,targets8] = SHLcharset8;
[alphabet9,targets9] = SHLcharset9;
[alphabet10,targets10] = SHLcharset10;

[R,Q] = size(alphabet)
[S2,Q] = size(targets);

% pre process data
% ================

[alphabet_pp,meanA,stdA]=prestd(alphabet) ;

[alphabet1,mean1,std1]=prestd(alphabet1) ;
[alphabet2,mean2,std2]=prestd(alphabet2) ;
[alphabet3,mean3,std3]=prestd(alphabet3) ;
[alphabet4,mean4,std4]=prestd(alphabet4) ;
[alphabet5,mean5,std5]=prestd(alphabet5) ;
[alphabet6,mean6,std6]=prestd(alphabet6) ;
[alphabet7,mean7,std7]=prestd(alphabet7) ;
[alphabet8,mean8,std8]=prestd(alphabet8) ;
[alphabet9,mean9,std9]=prestd(alphabet9) ;
[alphabet10,mean10,std10]=prestd(alphabet10) ;


P = alphabet_pp; % 88 rows , 35 columns
T = targets; % 35 by 35 matrixs

% DEFINING THE NETWORK
% ====================

% The character recognition network will have 25 TANSIG
% neurons in its hidden layer.

%S1 = 10;
S1 = 25;
net = newff(minmax(P),[S1 S2],{'logsig' 'logsig'},'trainscg n');

net = init(net); % weight & bias initialization

net.IW{1,1} = 1/sqrt(R) * (2*rand(size(net.IW{1,1}))-1); % R = 88 !!!
net.b{1} = 1/sqrt(R) * (2*rand(size(net.b{1}))-1);

net.LW{2,1} = 1/sqrt(S1) * (2*rand(size(net.LW{2,1}))-1);
net.b{2} = 1/sqrt(S1) * (2*rand(size(net.b{2}))-1);

% TRAINING THE NETWORK WITHOUT NOISE ( IDEAL CASE )
% =================================================

net.performFcn = 'sse'; % Sum-Squared Error performance function

net.trainParam.goal = 0.3; % % Sum-squared error goal.
net.trainParam.show = 20; % Frequency of progress displays (in epochs).
net.trainParam.epochs = 500; % Maximum number of epochs to train.
net.trainParam.mc = 0.95; % Momentum constant.
net.trainParam.lr = 0.0001 ;

[net,tr] = train(net,P,T);

save NNforCharRec net
%save NNforCharRec

% TRAINING THE NETWORK WITH NOISE ( 3 sets )
% ===============================

% A copy of the network will now be made. This copy will
% be trained with noisy examples of letters of the alphabet.

netn = net;

netn.trainParam.goal = 1e1; % Mean-squared error goal.
netn.trainParam.epochs = 500; % Maximum number of epochs to train.

% The network will be trained on 11 sets of noisy data collected from the samples.

T = [targets targets1 targets2 targets3 targets4 targets5 targets6 targets7 targets8 targets9 targets10];

for pass = 1:11
fprintf('Pass = %.0f\n',pass);
P = [alphabet_pp, alphabet1, alphabet2, alphabet3, alphabet4, alphabet5, alphabet6, alphabet7, alphabet8, alphabet9, alphabet10];

% pre processing
PN = trastd(P,meanA,stdA);

[netn,tr] = train(netn,PN,T);
end

% save NNforCharRec netn
save NNforCharRec

8 posts.
Tuesday 15 February, 04:34
Reply