Hello everyone!! Welcome back to Neural
Network Lectures. In this lecture, we are going to
discuss about how to implement various Logic Gates using McCulloch Pitts Model.
Before going on to that I hope that
everyone is familiar with the nonlinear
model of neuron. So let us, take a quick glance to it, okay? So, this is the
nonlinear model of neuron where we have
the input nodes over here, that is X1 X2
etc.. to Xn. Then we have W11
W12 W13 and I hope that everyone is
familiar with the notations. Then we have
a linear summariser of Vk which is given
by Vk equal to sigma j equal to 1 to n
Xj Wkj and this goes into an
activation function and we get Yk equal
to phi of Vk, okay? Now this model will
become a McCulloch-Pitts model where we
give a bias to it. Let bias be theta K
So this Vk ultimately becomes Vk
equal to j equal to 1 to n Xj Wkj plus
theta K ,right? Therefore the output will
be Yk equal to Phi of Vk that is
sigma j equal to 1 to n Xj Wkj plus
theta K, okay? And instead of leaving this
theta K over here, I can give it as an
input right here, So that is I'll give another
source node and set it's input as
X0 equal to 1. Then I join it to
here then I'll give the weight over here
as theta K, okay? Then another condition for this to be
a McCulloch-Pitts model is
that the activation function should be
threshold function. That is, Phi of Vk should be 1 when Vk take greater
than or equal to 0 and 0 then Vk less
than 0. I hope that everyone is familiar
with this. Now we'll try to implement the
logic AND gate, okay? So first we need to draw
the Truth Table for AND gate. That is, A be y 0 0
0 1 1 0 1 1 and outputs are 0 0 0 1
right? so we know that Vk equal to Sigma
Xj Wkj plus theta K right? But in this particular case
we have only two inputs so this n equal
to 2 This becomes X1 W11 plus X2 W12
plus theta 1, ok? And you have we also
have only one output neuron therefore k
equal to 1 and this is X1 this is X2
and this is Y1. According to threshold
function we know that Phi of Vk,ie Yk, will be one when Vk is greater
than 0  and 0
when Vk is less than 0. So what we need to
do is we need to adjust the bias theta1
in such a way that only this
case Vk will be greater than 0 or equal
to 0 and in all these cases Vk
should be less than 0. So let us try to
implement that.. So let us take this row
that is row 1 that. Before that, let us, for
initialization take W11 equal to 1 W12
equal to 1 and theta K equal to minus 1
theta 1 equal to minus 1. This is random
assumption and you can take whatever values you like, okay? But it will be easy
if we take our w11 equal to 1 W12 equal to 
1 and theta.. you'll see, okay? And now we can
see V1 equal to x1, that is 0 in
this case, okay?  0 x 1 plus X2
that is 0 x 1 plus theta K that is
1 and this is equal to 1 which is
greater than 0. Therefore we got V1
greater than 0 which means output will
be 1. But we need the output to be 0. Therefore we need to update the value of
theta1 therefore let us take theta1
equal to minus 1. So V1 will be, in
similar fashion, f0 x 1 plus 0 x 1 plus minus 1. So this is equal to
minus 1 and less than 0. Therefore V1<0 and we got the output
as y equal to 0. So our condition is
satisfied for the first row. Now we need
to check for the second row. Therefore row 2. The inputs are X1 equal to 0 x1 +
this is bias, okay? One.  And the x2=1
1 x W12, that is 1, and the value of bias is
currently is minus 1, okay? Therefore
minus 1, and we will get it as 0. And we
know that V1 is greater than or
equal to 0, we have the output to be 1
But we need the output to be 0. Therefore,
let us update the bias to be theta1 = -1.5
 okay? And let us write
V1 again. V1 = 0 x 1 + 1 x 1 - 1.5
which is
-0.5. Therefore, in this case,  V1 is less
than 0 and we get y equal to 0 hence it's
satisfied for row 2. Now, check again for
row 1. You'll find that row 1 will become
now V1 = -1.5
Thus, this bias is satisfied for Row 1
and Row 2. Now we should go to Row 3, okay?
That is, this case so. For Row 3
V1 equal to..... what is the input? X1 is 1 and
X2 is 0, okay?
1x1 + 0x1 minus the current bias is 1.5,
right? And we will get it as -0.5
Therefore V1 is less than 0,
implies y1 is equal to 0 and
that is the output we needed, okay? So we
don't need to update the bias. Now, let us
check for Row 4 and here we know that x1=1 and X=1. Therefore,
V1 = 1x1 + 1x1 - 1.5 which we get as 0.5 and V1
is greater than or equal to 0 implies
Y1 equal to 1. Therefore, if you check
you can see that for Row 1 we got the
output as 0, for Row 2 we got the output
as 0, Row 3 we got the output as 0 and
row 4 we got the output as 1. So this was
the condition we needed to implement the
logic AND gate, right? So, we can finally write
the equation finally as Vk = X1 x 1 + X2 x 1 - 1.5. Now, if you
draw the McCulloch-Pitts model for this
you have X0 = 1.... X 1 and X 2,
then we have the linear summarizer over
here and this is bk = -1.5 and
this is w11 = 1 & this is W12 = 1 and here there is V1 and this
goes to the activation function Phi(V1)
and we get the output. So this is the AND
gate implementation using McCulloch-Pitts model. Now, we'll see for the OR Gate.
Proceeding in a similar fashion,
first, we need to write the truth table,
okay? so A BY 0 0 0 1 1 0 1 1 and this
should be 0 1 1 1
Now, write Vk equal to X1 x W11 + X2 x W12 + thetak, ok? And let us
assume W11 = 1, W12 = 1 and
thetak =  1. Now takeing for Row 1
Vk = 0 x 1 + 0 x 1+ 1 = 1, therefore, we can see
that Vk is greater than or equal to 0
implies Yk = 1.  But, we need the Yk
to be zero. So let us update the bias
thetak to -1. Now,
Vk will be 0 x 1+ 0 x 1 + -1 which gives us -1 implies Vk
is less than 0 implies Yk equal to 0
Therefore, for the first row, we have
cleared. Now moving on the second row,
Row 2. Vk = 0 x 1 + 1 x 1 +  -1
which gives us 0. And we know that,
for Vk greater than or equal to 0
Yk is 1. Therefore, for the second row
also, it is cleared. Now, we will move on
to the third row, ok? Row 3. V1 = 1 x 1 + 0 x 1 - 1, which is 0
and we know that Vk greater than
or equal to 0, Yk = 1 and the required output
to was also 1. So it is cleared for Row 3
also. Now we'll check into row 4. And V1 is
1 x 1 + 1 x 1 - 1, which is 1.
And we know that for Vk greater than
or equal to 0, we have Yk = 1. Therefore, the outputs are,
for Row 1, it is 0, for row 2
it is 1, Row 3 is 1 and row 4 is 1. Thus we have
implemented the OR gate, right? So now
drawing the McCulloch-Pitt's model, we
have 3 input nodes. This is X 2 this is X
1 and this is X0 = 1. And
there's a linear summariser. We
have the bias bk = - 1
This is W11 = 1, W12 =1 and
this is Vk,  there's an activation
function Phi(Vk) and there is output,
okay? Now we'll try to implement the
McCulloch-Pitts model for NOT gate, okay? Here also,
as usual, we will draw the truth table
first, which is  X Y0 1 1 0
and this will be X1and this
will be Y1. Since, here is only one
output V1 will be X1 x W11
plus Thetak, okay? Now to initialise for
Row 1,  let us take W11 = 1
and thetak = -1, okay? Now, for Row 1, you
have V1 = 0 x 1 - 1
equal to minus 1 which is less than 0
therefore our output y 1 will be 0 but
we need the output to be what therefore
let us update the theta K 2 plus 1 now
even equal to 0 into 1 plus 1 go to 1
which is greater than or equal to 0
therefore our output will be only 1
therefore the condition is satisfied for
Row 1 now let's state pro 2 and even
equal to 1 into 1 plus 1 this 2 is
greater than or equal to 0 therefore
output will be 1 but we need the output
to be 0 now we have already tried that
negative value for theta here that is
minus 1 right so it is not necessary
that we should change the title you can
see his W 1 will also so let us try with
the W 1 1 equal to minus 1 therefore
even equal to only 2 minus minus 1 plus
1 which is equal to 0 here the steal the
output will be finally will do 1
therefore let us try updating the theta
K game ok so let us let Peter K equal to
0.5 therefore our output for second row
will become 1 into minus 1 this tap the
one you know T plus 0.5 which is minus
0.5 which is less than 0 therefore
output will be y1 equal to 0 as needed
okay now let us cross check the cycle
401 401 we even equal to 0 into minus 1
plus 0.5 which is equal to point right
later than or equal to 0 therefore y1
you can do what this for Row 1 we have
output us 1 and Row 2 we have output us
theorem this shows what is
right see here also funny disabled
therefore we have implemented the not
Gators BK equal to minus 1 X 1 plus
point 5 see this is just one of the
possible combinations you can actually
find many possible combinations sub to
you ok this is what I did to you
therefore according to this let us draw
the metal of its model and there is two
input nodes this is X 1 this is the bias
bias is equal to 0.5 that is the give me
a Sun Visor and definitely 1 1 is equal
to minus 1
it is the activation function then here
is the output okay now let us try to
implement the nor gate using macadam its
model okay and i just draw the truth
table first a while 0 0 0 1 1 0 1 would
write and outputs are 1 0 0 0 okay and
let this be X 1 let this be X 2 let this
be Y 1 1 equal to X 1 W 1 1 plus X 2 W 1
2 this Peter K okay let us take for
excellence theta 1 let us take W 1 1
equal to 1
don't you want to equal T 1 and theta 1
equal to minus 1 okay this is a random a
section for Rho 1 u 1 will be doing this
0 into 1 plus 0 into 1 plus minus 1
which is minus 1 and this less than or
equal to 0 therefore while K will be 0
we need to output the P 1 therefore let
us update theta 1 to 1 now V 1 will be 0
into 1 plus 0 into 1 plus 1 into 1 which
is greater than or equal to 0 sorry here
there is only less than 2 look it there
for y equal to 1 therefore the condition
for Row 1 is satisfied now let's check
for odd okay even equal to 0 into 1 plus
1 into 1 plus 1
which is equal to 2 which is greater
than or equal to zero therefore while k
equal to 1 but we need the YP to be 0
right so let us try to change W 1 and W
1 from here okay so that W 1 min equal
to minus 1 and W 1 2 equal to minus 1
now these are random assumptions are you
can take her whatever I need you like
okay and just try to enforce this
condition that is P 1 greater than or
the literal okay therefore here coming
to our W 1 1 end up you want to even it
will be 0 into minus 1 plus 1 into minus
1 plus 1 this is 0 which is still
greater than or equal to 0 therefore YK
equal to 1 okay so this doesn't work
either so let us try to update theta
12.5 therefore even will now become an
equal to figure out the minus 1 plus 1
into minus 1 plus 0.5 you get it is
minus 0.5 which is less than 0 therefore
YK will be 0 therefore our condition for
Rho into it is also satisfied then is
check for probably even will be 1 into
minus 1 plus 0 into minus 1 plus 0.5
which is also minus 0.5 less than 0
therefore YT is equal to 0 this is the
condition is satisfied for Row 3 also
now let us set for Prabhu
this is given equal to 1 into minus 1
plus 1 into buying this 1 plus 0.5 this
equal to minus 1.5 this also less than 0
therefore y equal to 0 satisfied our
last condition also right therefore it
can write P 1 equal to X 1 into minus 1
plus X 2 into minus 1 plus 0.5 you see
this we can implement the buckle up its
model as three input notes okay it's
forbidden one so there's a linear
surpriser
so this is minus ETA equal to point 5
this is tuptim 1 1 multiplying this 1
this is X 1 X 2 this is w 1 to 32 minus
1 and this is 1
or through an activation function by
okay but human Purdue but this we have
explained prevented the nor gate also
now in signal fashion you can implement
the name it also you can try that as a
home focus you know the methodology
right and in the next lecture we will
trying to implement the XO and X nor
gates and also the implementation logic
ant and or gate loose it can be el
principe okay so that's all for today's
lecture thank you for watching and have
a good
