
First, we need to know that the Perceptron algorithm states
that:
Prediction (y`) = 1 if Wx+b > 0 and 0 if Wx+b ≤ 0
Also, the steps in this method are very similar to how Neural
Networks learn, which is as follows;
- Initialize weight values and bias
- Forward Propagate
- Check the error
- Backpropagate and Adjust weights and bias
- Repeat for all training examples
Now that we know the steps, let’s get up and running:
NAND Gate

From the diagram, the NAND gate is 0 only if both inputs are
1.
Row 1
- From w1x1+w2x2+b, initializing w1 and w2 as 1, and b as -1, we
get;
x1(1)+x2(1)-1
- Passing the first row of the NAND logic table (x1=0, x2=0), we
get;
0+0-1 = -1
- From the Perceptron rule, if Wx+b≤0, then y`=0. This row is
incorrect, as the output is 1 for the NAND gate.
- So we want values that will make input x1=0 and x2 = 0 to give
y` a value of 1. If we change b to 1, we have;
0+0+1 = 1
- From the Perceptron rule, this works.
Row 2
- Passing (x1=0, x2=1), we get;
0+1+1 = 2
- From the Perceptron rule, if Wx+b > 0, then y`=1. This row
is also correct (for both row 2 and row 3).
Row 4
- Passing (x1=1, x2=1), we get;
1+1+1 = 3
- This is not the expected output, as the output is 0 for a NAND
combination of x1=1 and x2=1.
- Changing values of w1 and w2 to -1, and value of b to 2, we
get;
-1-1+2 = 0
Therefore, we can conclude that neural network to
achieve a NAND gate, using the Perceptron algorithm is;
-x1-x2+2
