Shape recognition by neural network
6 次查看(过去 30 天)
显示 更早的评论
Hello, I would like to ask which Neural Network should I choose. I want to recognition of 3 shape (Square,Circle,Triangle).
I learn my NN with 69 patterns (23 image of Square, 23 Circle etc). First network was "newp" and the second "newff". I have some answers but my network recognition e.g Triangle as Square and Circle or something like this. Any ideas ? Thank !
% PATTERNS
load PatternsSquare
load PatternsCircle
load PatternsTriangle
% SHAPE Square
P1=cell2mat(struct2cell(PatternsSquare));
PS=reshape(P1,40000,23);
% SHAPE Circle
P2=cell2mat(struct2cell(PatternsCircle));
PO=reshape(P1,40000,23);
% SHAPE Triangel
P3=cell2mat(struct2cell(PatternsTriangle));
PT=reshape(P1,40000,23);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NETWORK
P=[PS,PO,PT]; %MATRIX WITH ALL MY PATTERN
T=eye(3,69); %NETWORK ANSWER
%net = newp(P,T,'hardlim','learnp');
net=newff(P,T,[10 10],{'tansig' 'purelin'},'traingd');
net.trainParam.epochs = 50;
net.trainParam.goal=0.00001;
net = train(net,P,T);
Y=sim(net,P);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DISRUPTION
D=imread('T14.png'); % MY DISRUPTION PATTERN
D=im2bw(D);
D=double(D);
[m n] = size(D) ;
D = imresize(D, [200 200]);
[x y] = size(D);
PD=reshape(D,40000,1);
YD=sim(net,PD);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% DISPLAY
figure(1)
for i=1:1
subplot(1,2,i)
imshow(reshape(PD(:,i),200,200))
title('DISRUPTION')
subplot(1,2,2*i)
hintonw(YD(:,i))
title('NEURON: 1-Square, 2-Circle, 3-Triangle')
end
0 个评论
采纳的回答
Greg Heath
2018-6-2
1.You have erroneouslyy defined PO and PT with P1
2. I think the argument in reshape should be (Pm,23,40000)
3. You have 2 hidden layers. One is sufficient.
4. I didn't look at Disruption and Display
Hope this helps.
Greg
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!