All '/nnitial Weights Are/n' 'Row of W/N' 'Column of W/N': Experiment: To Implement The Hebb'S Rule Program

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

EXPERIMENT : TO IMPLEMENT THE HEBBS RULE

PROGRAM:

clear all
clc
fprintf('\nnitial weights are\n');
wr=input('row of w\n');
wc=input('column of w\n')
for i=1:wr
for j=1:wc
w(i,j)=input('values\n');
end
end
display(w);
xr=input('row of x\n');
xc=input('column of x\n');
for i=1:xr
for j=1:xc
x(i,j)=input('values');
end
end
display(x);
c=input('value of learning constant\n');
n=input('number of input datapoints\n');
for i=1:n;
xn=x(:,i);
display(xn);
net=w.'*xn;
display(net);
func=sign(net);
func1=0.5*(1-func^2);
w1=c*(t(:,i)-func)*func1*xn;
w=w+w1;
end
fprintf('\nThe final updated weights are\n')
display(w)

You might also like