Created
November 8, 2012 12:04
-
-
Save ghdawn/4038397 to your computer and use it in GitHub Desktop.
a example of perceptron(Artifial Neural Network)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [w,flag] = learning(flag,w,omega,target ) | |
%UNTITLED3 Summary of this function goes here | |
% Detailed explanation goes here | |
ita=1; | |
result=(omega*w)>0; | |
result=target-result; | |
for i = 1 : 3 | |
if result(i) == 0 | |
continue | |
end | |
flag=0; | |
w=w+2*ita*result(i)*omega(i,:)' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
omega1=[0,1;0,2;1,1]; | |
omega2=[2,0;3,0;3,1]; | |
plot(omega1(:,1),omega1(:,2),'r*'); | |
hold on; | |
plot(omega2(:,1),omega2(:,2),'gx'); | |
x0=[-1;-1;-1] | |
omega1=[x0,omega1]; | |
omega2=[x0,omega2]; | |
w=rand(3,1) | |
flag=0; | |
while flag==0 | |
flag=1; | |
[w,flag]=learning(flag,w,omega1,ones(3,1)); | |
[w,flag]=learning(flag,w,omega2,zeros(3,1)); | |
end | |
x=0:4; | |
plot(x,w(1)/w(3)-x*w(2)/w(3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment