multi layer digit recognition
Afficher commentaires plus anciens
i am working on simple codes in matlab for neural networks
i need matlab code for network to recognize numbers 0 to 9 {binary numbers recognition}...and training and testing of network by multi layer perceptron.
those are my input
%perceptron digit recognition
clc
%datas
%Original inputs
d0=[0;1;1;1;0;1;0;0;0;1;1;0;0;0;1;1;1;0;0;0;1;1;0;0;0;1;0;0;0;1;0;1;1;1;0];
d1=[0;0;1;0;0;0;1;1;0;0;0;0;1;0;0;0;0;1;0;0;0;0;1;0;0;0;0;1;0;0;0;1;1;1;0];
d2=[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];
d3=[1;1;1;1;1;0;0;0;0;1;0;0;0;0;1;1;1;1;1;1;0;0;0;0;1;0;0;0;0;1;1;1;1;1;1];
d4=[0;0;0;1;0;0;0;1;1;0;0;1;0;1;0;1;0;0;1;0;1;1;1;1;1;0;0;0;1;0;0;0;0;1;0];
d5=[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;1;0;0;0;1;1;1;1;1;1];
d6=[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;1;0;0;0;1;1;1;1;1;1];
d7=[1;1;1;1;1;0;0;0;0;1;0;0;0;1;0;0;0;1;0;0;0;1;0;0;0;0;1;0;0;0;0;1;0;0;0];
d8=[1;1;1;1;1;1;0;0;0;1;1;0;0;0;1;1;1;1;1;1;1;0;0;0;1;1;0;0;0;1;1;1;1;1;1];
d9=[1;1;1;1;1;1;0;0;0;1;1;0;0;0;1;1;1;1;1;1;0;0;0;0;1;0;0;0;0;1;1;1;1;1;1];
% Added bias
b=1;
d0=[1;1;1;1;1;1;0;0;0;1;1;0;0;0;1;1;1;0;0;0;1;1;0;0;0;1;0;0;0;1;0;1;1;1;0;b];
d1=[0;0;1;0;0;0;1;1;0;0;0;0;1;0;0;0;0;1;0;0;0;0;1;0;0;0;0;1;0;0;0;1;1;1;0;b];
d2=[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;b];
d3=[1;1;1;1;1;0;0;0;0;1;0;0;0;0;1;1;1;1;1;1;0;0;0;0;1;0;0;0;0;1;1;1;1;1;1;b];
d4=[0;0;0;1;0;0;0;1;1;0;0;1;0;1;0;1;0;0;1;0;1;1;1;1;1;0;0;0;1;0;0;0;0;1;0;b];
d5=[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;b];
d6=[1;1;1;1;1;1;0;0;0;0;1;0;0;0;0;1;1;1;1;1;1;0;0;0;1;1;0;0;0;1;1;1;1;1;1;b];
d7=[1;1;1;1;1;0;0;0;0;1;0;0;0;1;0;0;0;1;0;0;0;1;0;0;0;0;1;0;0;0;0;1;0;0;0;b];
d8=[1;1;1;1;1;1;0;0;0;1;1;0;0;0;1;1;1;1;1;1;1;0;0;0;1;1;0;0;0;1;1;1;1;1;1;b];
d9=[1;1;1;1;1;1;0;0;0;1;1;0;0;0;1;1;1;1;1;1;0;0;0;0;1;0;0;0;0;1;1;1;1;1;1;b];
2 commentaires
Greg Heath
le 9 Avr 2012
I am confused. Please explain exactly what the inputs and targets are. What are the dimensions of the input and target matrices?
Greg
yahya m
le 11 Avr 2012
Réponse acceptée
Plus de réponses (1)
Greg Heath
le 11 Avr 2012
0 votes
%You don't need all of those semicolons to represent a column vector. Just transpose the corresponding row vector.
x = [ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 ]; % Input Matrix
t = eye(10); % Target Matrix
[ I N ] = size(x) % = [ 35 10 ]
[ O N ] = size(t) % = [ 10 10 ]
Neq = N*O % = 100 No. of training equations
% For an I-H-O MLP with H hidden nodes, the number of unknown weights (includes biases) is
%Nw = (I+1)*O+(H+1)*O
% For training to convergence without regularization or validation stopping, Neq >= Nw which yields the following upper bound on H:
Hub = floor((Neq-O)/(I+O+1)) % = 1
% Therefore H = 0 (Linear Classifier) and H = 1 could be used if they perform well enough. However, to mitigate measurement error, noise and interference on nontrainingdata, it is desired that H << Hub. Obviously, there is not enough data here for that.
% Common solutions when there is only one data example per class
1. Add enough noisy versions of the input vectors to increase N enough so that Neq >> Nw (i.e., H << Hub) for any given value of H.
2. Use additional noisy vectors so that N is large enough to yield reasonable numbers of vectors for training, validation and test subsets. Then enable validation stopping which does not require H << Hub.
3. Use regularization (help/doc trainbr) which also does not require H << Hub.
Very often I search over a hidden node outer loop H = Hmin:dH:Hmax with a random weight initialization inner loop (weighttrial = 1:10) to find the smallest value of H that will yield acceptable results.
Look at the several classification demos in the Neural network Toolbox.
Hope this helps.
Greg
2 commentaires
Greg Heath
le 11 Avr 2012
I don't understand the purpose of the "add bias" version. This results in a constant row that is ignored by the training programs.
If you are adding it because you want a bias term in the hidden node input, DON'T ... it is always automatically included.
Hope this helps.
Greg
yahya m
le 11 Avr 2012
Catégories
En savoir plus sur Deep Learning Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!