Pattern Recognition with Perceptron

6 次查看(过去 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

采纳的回答

Chandra Kurniawan
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
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 CenterFile Exchange 中查找有关 Pattern Recognition and Classification 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by