Today we will be discussing Logical gates using tensorflow2 API.AND, NOR and OR Gates can be calculated by a single perceptron.At first, we will build AND, NOR, and OR Gates. We will be keeping the Input as Same and will be changing the outputs to calculate AND, OR, and NOR gates.
Truth table for AND, OR and NOR gates
We will be using tensorflow2 API in this tutorial. You can know the version of your TensorFlow just by running the following command in your Jupyter notebook.
import tensorflow as tf
print(tf.__version__)
#!pip install --upgrade tensorflow
Now, we will initialize all our training examples which in our case is only four.
# Let us initialize our training examples first.
import tensorflow as tf
X1=tf.Variable(initial_value=[0.,1.,0.,1.])
X2=tf.Variable(initial_value=[0.,0.,1.,1.])
Y_AND=tf.Variable(initial_value=[0.,0.,0.,1.])
Y_NOR=tf.Variable(initial_value=[1.,0.,0.,0.])
Y_OR=tf.Variable(initial_value=[0.,1.,1.,1.])
Y_XOR=tf.Variable(initial_value=[0.,1.,1.,0.])
Y_XNOR=tf.Variable(initial_value=[1.,0.,0.,1.])
We will create a Model class where we would do the following
#neural-networks #tensorflow2 #tensorflow-api #api