multi layer digit recognition

조회 수: 3 (최근 30일)
yahya m
yahya m 2012년 4월 8일
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
Greg Heath
Greg Heath 2012년 4월 9일
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
yahya m 2012년 4월 11일
thank u for ur response also i am sorry about some detailes...
input = the matrix dimension for each digit is 5*7=35
this means that 350
the weights has the dimension of 10*35
the target is eye(10) matrix
1 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 1
we need that when we enter digit 0 examine the network ability to recognize this digit...also for the other numbers 1 to 9.
and the two matrix which i put before gives the original data and the other for original data with bias.

댓글을 달려면 로그인하십시오.

채택된 답변

Greg Heath
Greg Heath 2012년 4월 12일
yahya m about 6 hours ago
>UNFORTUNATELY i dont have good experience in NN because iam new... but for inputs ok and for training i am looking for matlab code for NN IN THE FORM OF
>p = [d0; d1; d2; d3 ; d4 ; d5 ; d6 ; d7 ; d8 ; d9]';
INCORRECT. REMOVE THE SEMICOLON TO SEE WHAT THAT GIVES YOU. THEN COMPARE WITH WHAT I HAVE WRITTEN PREVIOUSLY.
>t = eye(10);
>PR = zeros(36,10);
>PR(:,10) = 1;
INCORRECT. DELETE PR
class = vec2ind(t)
>net = newp(PR,3,'hardlim');
NO. USE NEWFF, NEWFIT or PATTERNNET
net = newff(p,t,H); % H = number of hidden nodes.
help/doc newff
>net.trainParam.epochs = 10;
NO. USE ALL AVAILABLE DEFAULTS. IF ANY DEFAULT IS FOUND TO BE INSUFFICIENT, CHANGE IT AND RERUN.
>net = train(net, p, t);
>a = sim(net, d')
NO. WHAT IS d'???
a = sim(net,p);
classa = vec2ind(a)
Nerr = sum(classa ~= class) % NUMBER OF CLASSIFICATION ERRORS
>LOOK FOR NEWP I NEED THE CODE OF THIS TYPE TO BE ENTRRED IN MATLAB IN ORDER TO EXAMINE THE NETWOR ABILITY TO RECOGNIZE THE DIGITS.
NO. DEPENDING ON THE TOOLBOX VERSION:
help newff
doc newff
help fitnet % REPLACED NEWFF IN LATEST VERSIONS OF TOOLBOX
doc fitnet
help patternet % NEW. SPECIALIZED FOR PATTERN RECOGNITION AND CLASSIFICATION.
doc patternnet
SEE THE CLASSIFICATION DEMOS IN THE TOOLBOX.
Hope this helps.
Greg

추가 답변 (1개)

Greg Heath
Greg Heath 2012년 4월 11일
%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
Greg Heath
Greg Heath 2012년 4월 11일
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
yahya m 2012년 4월 11일
UNFORTUNATELY i dont have good experience in NN because iam new...
but for inputs ok and for training i am looking for matlab code for NN IN THE FORM OF
p = [d0; d1; d2; d3 ; d4 ; d5 ; d6 ; d7 ; d8 ; d9]';
t = eye(10);
PR = zeros(36,10);
PR(:,10) = 1;
net = newp(PR,3,'hardlim');
net.trainParam.epochs = 10;
net = train(net, p, t);
a = sim(net, d')
LOOK FOR NEWP I NEED THE CODE OF THIS TYPE TO BE ENTRRED IN MATLAB IN ORDER TO EXAMINE THE NETWOR ABILITY TO RECOGNIZE THE DIGITS.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by