Implementation of Perceptron Algorithm for XOR Logic Gate with 2-bit Binary Input
In the field of Machine Learning, the Perceptron is a Supervised Learning Algorithm for binary classifiers. The Perceptron Model implements the following function:
For a particular choice of the weight vector and bias parameter , the model predicts output for the corresponding input vector .
XOR logical function truth table for 2-bit binary variables, i.e, the input vector and the corresponding output –
We can observe that,
Designing the Perceptron Network:
- Step1: Now for the corresponding weight vector of the input vector to the AND and OR node, the associated Perceptron Function can be defined as:
- Step2: The output from the AND node will be inputed to the NOT node with weight and the associated Perceptron Function can be defined as:
- Step3: The output from the OR node and the output from NOT node as mentioned in Step2 will be inputed to the AND node with weight . Then the corresponding output is the final output of the XOR logic function. The associated Perceptron Function can be defined as:
For the implementation, the weight parameters are considered to be and the bias parameters are .
XOR(0, 1) = 1 XOR(1, 1) = 0 XOR(0, 0) = 0 XOR(1, 0) = 1
Here, the model predicted output () for each of the test inputs are exactly matched with the XOR logic gate conventional output () according to the truth table.
Hence, it is verified that the perceptron algorithm for XOR logic gate is correctly implemented.