In machine learning, the perceptron is an algorithm for supervised classification of an input into one of several possible non-binary outputs. It is a type of linear classifier, i.e. a classification algorithm that makes its predictions based on a linear predictor function combining a set of weights with the feature vector. The algorithm allows for online learning, in that it processes elements in the training set one at a time.
The perceptron algorithm dates back to the late 1950s. Its first implementation, in custom hardware, was one of the first artificial neural networks to be produced.
PROGRAM
% Prajwal's Neural Network :P :P
clear all
close all
clc;s=0;ch=0;
e=input('enter the enable input for training (either 1 or 0): ');
l=input('for bipolar inputs, press "-1". For binary inputs, press "0": ');
x=input('enter the input matrix (order: 4x2): ');
t=input('enter the target matrix (order: 4x1): ');
w=input('enter the weight matrix (order: 2x1): ');
b=input('enter the bias: ');
lr=input('enter the learning rate: ');
it=input('enter the no.of iterations to be performed: ');
y=[0; 0; 0; 0];
if(e==1)
for s=1:it
ch=0;
for q=1:4
yin=b+x(q,1)*w(1,1)+x(q,2)*w(2,1);
if(yin<0)
y(q,1)=l;
else
y(q,1)=1;
end
if(y(q,1)~=t(q,1))
w(1,1)=w(1,1)+lr*t(q,1)*x(q,1);
w(2,1)=w(2,1)+lr*t(q,1)*x(q,2);
b=b+lr*t(q,1);
else
ch=ch+1;
end
end
if ch==4
break;
end
end
end
disp(s);
disp(w);
disp(y);
- Training your neural network based on the algorithm specified above comes under SUPERVISED LEARNING.
- In perceptron based learning, we should initialize weights to zero. But you can even initialize them with any random values as shown in simulation.
- If weights aren't initialized with 0, it becomes another different learning algorithm
For any queries regarding code or anything else regarding any post in my blog, contact me at pj.kotamraju225@gmail.com. See you people with a new conclusion within no time ;) :D
No comments:
Post a Comment
Any queries ?