In the field of Machine Learning, the Perceptron is a Supervised Learning Algorithm for binary classifiers. The Perceptron Model implements the following function:
![Rendered by QuickLaTeX.com \[ \begin{array}{c} \hat{y}=\Theta\left(w_{1} x_{1}+w_{2} x_{2}+\ldots+w_{n} x_{n}+b\right) \\ =\Theta(\mathbf{w} \cdot \mathbf{x}+b) \\ \text { where } \Theta(v)=\left\{\begin{array}{cc} 1 & \text { if } v \geqslant 0 \\ 0 & \text { otherwise } \end{array}\right. \end{array} \]](https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-f98cbf4744582c2b3309f1b0ceb8a313_l3.png)
For a particular choice of the weight vector
and bias parameter
, the model predicts output
for the corresponding input vector
.
NOT logical function truth table is of only 1-bit binary input (0 or 1), i.e, the input vector
and the corresponding output
–
 |
 |
0 |
1 |
1 |
0 |
Now for the corresponding weight vector
of the input vector
, the associated Perceptron Function can be defined as:
![Rendered by QuickLaTeX.com \[$\boldsymbol{\hat{y}} = \Theta\left(w x+b\right)$\]](https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-ffc911fc71ed0749b941afac38e76081_l3.png)

For the implementation, considered weight parameter is
and the bias parameter is
.
Python Implementation:
import numpy as np
def unitStep(v):
if v > = 0 :
return 1
else :
return 0
def perceptronModel(x, w, b):
v = np.dot(w, x) + b
y = unitStep(v)
return y
def NOT_logicFunction(x):
w = - 1
b = 0.5
return perceptronModel(x, w, b)
test1 = np.array( 1 )
test2 = np.array( 0 )
print ( "NOT({}) = {}" . format ( 1 , NOT_logicFunction(test1)))
print ( "NOT({}) = {}" . format ( 0 , NOT_logicFunction(test2)))
|
Output:
NOT(1) = 0
NOT(0) = 1
Here, the model predicted output (
) for each of the test inputs are exactly matched with the NOT logic gate conventional output (
) according to the truth table.
Hence, it is verified that the perceptron algorithm for NOT logic gate is correctly implemented.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
08 Jun, 2020
Like Article
Save Article