You are on page 1of 20

Applications of Soft Computing

Lecture 4
M-P Neuron Model
The McCulloch-Pitts neuron was the earliest neural network
discovered in 1943.
The M-P neurons are connected by directed weighted paths.
The activation function of an M-P neuron is binary, that is,
at any time step the neuron may fire or may not fire.
The weights associated with the communication links may
be excitatory (weight is positive) or inhibitory (weight is
negative).
M-P Neuron Model
There is a fixed threshold for
each neuron, and if the net
input to the neuron is greater
than the threshold then the
neuron fires.
Connection is excitatory with
weight w (w > 0) or inhibitory
with weight –p (p < 0).
 Here, yin is net input.
Activation function is:-
M-P Neuron Model
The M-P neuron has no particular training algorithm.
An analysis has to be performed to determine the values of
the weights and the threshold.
Here the weights of the neuron are set along with the
threshold to make the neuron perform a simple logic
function.
The M-P neurons are used as building blocks on which we
can model any function or phenomenon, which can be
represented as a logic function.
Example 1
Implement AND function using M-P Neuron Model:
What is the 1st thing we need for implementation?
(Training Data)
The truth table for AND function is:

X1 X2 Y
1 1 1
1 0 0
0 1 0
0 0 0
Example 1 (AND using M-P)
How AND function is represented?
Y = X1 . X2

What will be the architecture of a Neural Network?


(Single layer / Multi layer)
How many Inputs?
2 (X1 and X2)
How many outputs?
1 (Y)
Example 1 (AND using M-P)
So the architecture of NN for AND is:
Now, We have input &
corresponding output. What do we need to
complete the
network?
X1 w1
θ
f Y

w2
X2
Example 1 (AND using M-P)
Now we know what we need, weights and threshold.
In M-P Neuron model, our basic assumptions are:
Here we do only analysis
Threshold will work as activation function
Weights can be excitatory (+ve) or inhibitory (-ve)
 Possible combinations are (both positive) (1 positive 1 negative) (both
negative)
 We will take the value of weights 1
 So possible weights are (+1, +1) (+1, -1) (-1, +1) (-1, -1)
We will use one from these combinations and try to set the
threshold for solving the problem.
Example 1 (AND using M-P)
Start by talking weights as w1=+1 and w2=+1
Next steps are:
We will calculate the net input(Yin) at neuron Y.
Try to set the Threshold θ such that Yin can be converted into Y.

Net input is calculated as:


Net
I/P O/P Weights Threshold Yin = W1X1 + W2X2 + …..
I/P
X1 X2 Y W1 W2 Yin θ
1 1 1 +1 +1 2
1 0 0 +1 +1 1
0 1 0 +1 +1 1
0 0 0 +1 +1 0
Example 1 (AND using M-P)
Net
I/P O/P Weights Threshold Output Threshold
I/P Compare
Yin with θ activation function
X1 X2 Y W1 W2 Yin
is:
if net input is ≥ θ
1 1 1 +1 +1 2 2≥2 1
θ=1 then output is 1
1 0 0 +1 +1 1 1≥2 0 otherwise 0.
0 1 0 +1 +1 1 1≥2 0
0 0 0 +1 +1 0 0≥2 0

Now, The final NN for AND =+1 =2


function is:

=+1
Example 2
Implement M-P Neuron Model for the function
Y = X1X2’

The Truth Table for this function is:


X1 X2 Y
1 1 0
1 0 1
0 1 0
0 0 0
Example 2
So the architecture of NN for the function is:

X1 w1
θ
f Y

w2
X2
Example 2
Start by talking weights as w1=+1 and w2=+1
Next steps are:
We will calculate the net input(Yin) at neuron Y.
Try to set the Threshold θ such that Yin can be converted into Y.

Net input is calculated as:


Net
I/P O/P Weights Threshold Yin = W1X1 + W2X2 + …..
I/P
X1 X2 Y W1 W2 Yin θ
1 1 0 +1 +1 2 Here we are not able to set any
1 0 1 +1 +1 1 threshold such that Yin can be
0 1 0 +1 +1 1 converted into Y.
0 0 0 +1 +1 0
Example 2
So we will use another combination of weights.
Now, we use W1 = +1 and W2 = -1

Net input is calculated as:


Yin = W1X1 + W2X2 + …..
As output is same as desired, so the
Net final weights are W1=+1 and W2=-1
I/P O/P Weights If θ = 1
I/P with threshold θ=1
X1 X2 Y W1 W2 Yin Output is
1 1 0 +1 -1 0 0
1 0 1 +1 -1 1 1
0 1 0 +1 -1 -1 0
0 0 0 +1 -1 0 0
Example 3
Implement XOR Gate using M-P Neuron Model

Truth table for XOR is:


X1 X2 Y Function of XOR
is:1 1 0
1 0 1 Y = X1X2’ + X1’X2
0 1 1 This function can not be solved by the
single layer neural network.
0 0 0
Here we need a hidden layer in our neural
net.
Example 3
Here we divide out function into sub parts.
Y = X1X2’ + X1’X2
Z1 Z2
Now we have 3 sub problems to solve:
Z1 = X1X2’ θ1
X W11 Z
Z2 = X1’X2 1 1 V11 θ3
W12 W21
Y = Z1+Z2 Y

X Z V21
2 W22 2
θ2
Example 3
O/ Net
I/P Weights If θ = 1
P I/P
For Z1
X1 X2 Z1 W11 W21 Z1in Output is
1 1 0 +1 -1 0 0
1 0 1 +1 -1 1 1
0 1 0 +1 -1 -1 0 O/ Net
I/P Weights If θ = 1
P I/P
0 0 0 +1 -1 0 0
X1 X2 Z2 W12 W22 Z2in Output is
1 1 0 -1 +1 0 0
1 0 0 -1 +1 -1 0
For Z2 0 1 1 -1 +1 1 1
0 0 0 -1 +1 0 0
Example 3
Now, we will solve our 3rd sub-problem.
We knows the value of Z1 and Z2.
Y = Z1 + Z2 Here Yin is calculated as:
Yin = Z1V1 + Z2V2
X1 X2 Y Z1 Z2 V1 V2 Yin Output θ=1
1 1 0 0 0 +1 +1 0 0
1 0 1 1 0 +1 +1 1 1
0 1 1 0 1 +1 +1 1 1
0 0 0 0 0 +1 +1 0 0

Same
as
Example 3
So the Neural net for XOR function is:

θ1 =1
X W11=+1 Z
1 1 V11=+1
W12=-1 θ3= 1
Y
W21=-1
X Z V21=+1
2 W22=+1 2
θ2=1
Exercises
Implement M-P neuron for following logic functions:
OR
NAND
XNOR

You might also like