Pattern Recognition with Perceptron
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi, all
I have six patterns as shown below
A1 = [ 0 0 1 1 0 0 0;
0 0 0 1 0 0 0;
0 0 0 1 0 0 0;
0 0 1 0 1 0 0;
0 0 1 0 1 0 0;
0 1 1 1 1 1 0;
0 1 0 0 0 1 0;
0 1 0 0 0 1 0;
1 1 1 0 1 1 1];
B1 = [ 1 1 1 1 1 1 1;
1 0 0 0 0 0 1;
1 0 0 0 0 0 1;
1 0 0 0 0 0 1;
1 1 1 1 1 1 1;
1 0 0 0 0 0 1;
1 0 0 0 0 0 1;
1 0 0 0 0 0 1;
1 1 1 1 1 1 1];
C1 = [ 0 0 1 1 1 1 1;
0 1 0 0 0 0 1;
1 0 0 0 0 0 0;
1 0 0 0 0 0 0;
1 0 0 0 0 0 0;
1 0 0 0 0 0 0;
1 0 0 0 0 0 0;
0 1 0 0 0 0 1;
0 0 1 1 1 1 0];
A2 = [ 0 0 0 1 0 0 0;
0 0 0 1 0 0 0;
0 0 0 1 0 0 0;
0 0 1 0 1 0 0;
0 0 1 0 1 0 0;
0 1 0 0 0 1 0;
0 1 1 1 1 1 0;
0 1 0 0 0 1 0;
0 1 0 0 0 1 0];
B2 = [ 1 1 1 1 1 1 0;
1 0 0 0 0 0 1;
1 0 0 0 0 0 1;
1 0 0 0 0 0 1;
1 1 1 1 1 1 0;
1 0 0 0 0 0 1;
1 0 0 0 0 0 1;
1 0 0 0 0 0 1;
1 1 1 1 1 1 0];
C2 = [ 0 0 1 1 1 0 0;
0 1 0 0 0 1 0;
1 0 0 0 0 0 1;
1 0 0 0 0 0 0;
1 0 0 0 0 0 0;
1 0 0 0 0 0 0;
1 0 0 0 0 0 1;
0 1 0 0 0 1 0;
0 0 1 1 1 0 0];
I have to recognize these patterns with artificial neural network.
I am new in Matlab. Please help!
I need to divide this data into 2 groups.
The first group A1, B1, C1 as training data. The second group A2, B2, C2 used to validate/test the network.
Example : if I select A1 then the output must display 'A', if I select B1 then the output must display 'B', if I select A2 then the output must display 'A'.
. . # # . . .
. . . # . . .
. . . # . . .
. . # . # . .
. . # . # . . => This pattern should be recognized as A
. # # # # # .
. # . . . # .
. # . . . # .
# # # . # # #
How do I do that?
Thanks in advance!
Network type is perceptron
댓글 수: 0
채택된 답변
Chandra Kurniawan
2012년 1월 26일
Hi, Benard
A perceptron can be created with the newp function.
Eq: net = newp(PR,S,TF,LF);
- PR is m x 2 matrix of [min max] of network input
- S is a scalar that indicates number of target/pattern
- TF is transfer function. Default is 'hardlim'
- LF is learning function. Default is 'learnp'
In order to divide your data into 2 groups, you need to select A1, B1, C1 as network input.
p = [A1(1:end); B1(1:end); C1(1:end)]';
And to create the network target
t = eye(3);
Then, use train to perform network training. You can also set the network epoch by :
net.trainParam.epochs = 10;
So, the complete code is :
p = [A1(1:end); B1(1:end); C1(1:end)]';
t = eye(3);
PR = zeros(63,2);
PR(:,2) = 1;
net = newp(PR,3,'hardlim','learnp');
net.trainParam.epochs = 10;
net = train(net, p, t);
And about how to test your network just use sim command.
a = sim(net, A2(1:end)');
Now, do testing for A1 and A2. Both of them will display :
>> a = sim(net, A2(1:end)')
a =
1
0
0
>> a = sim(net, A1(1:end)')
a =
1
0
0
댓글 수: 5
Greg Heath
2012년 1월 26일
If you have the typical problem of identifying the 26 alphabet characters and 10 digits, you will probably need to add a hidden layer via newff or patternnet.
Hope this helps.
Greg
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!