First Neural Network Model
- If we touch something cold we perceive heat.
- If we keep touching something cold we will perceive cold.
- If we touch something hot we will perceive heat.
- To model this we will assume that time is discrete.
- If cold is applied for one time step then heat will be perceived.
- If a cold stimulus is applied for two time steps then cold will be perceived.
- If heat is applied then we should perceived heat.
% Logic AND Not function by McCulloch-Pitts neuron model
clear;
clc;
x1 = [1 1 0 0 1 1 0 0]; % input first
x2 = [1 0 1 0 1 0 1 0]; % input second
x3 = [1 1 1 1 0 0 0 0]; % input third
t = [0 1 0 0 0 1 0 0]; % target output
y = [0 0 0 0 0 0 0 0]; % calculated output
w = [1 -1]; % weights of AND not
w1 = [3 3]; % weights of OR
yy = [0 0 0 0 0 0 0 0]; % calculated_output
tt = [1 1 1 1 0 1 0 0]; % target_output
con = 1;
while con
con = 0;
for i= 1:8
%net input formula
y_in = x1(i)*w(1)+x2(i)*w(2); %eq form ch 3 or 4
%applying activation formula
if y_in >= 1
y(i) = 1;
end
if y_in < 1
y(i) = 0;
end
end
for i = 1:8
y_in = w1(1)*x3(i) + w1(2)*y(i);
%applying activation formula
if y_in >= 3
yy(i) = 1;
end
if y_in < 3
yy(i) = 0;
end
end
end
if yy == tt
disp('Calculated output is equal to target output');
for i = 1:8
if yy(i) ==1
sprintf('Value is %d, So output is Cold',yy(i))
else
sprintf('Value is %d, So output is Hot',yy(i)')
end
end
else
disp('not equal');
end
0 Comments