0% found this document useful (0 votes)
36 views2 pages

Deep Learning Lab 1

Uploaded by

pingtokrithika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

Deep Learning Lab 1

Uploaded by

pingtokrithika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PMDS603P Deep Learning Lab Experiment 1

July 2025

1 Work to do today
Note: Make a single PDF file of the work you are doing in Jupyter notebook. Upload with
the proper format. Please mention your name and roll no properly with the Experiment
number on the first page of your submission.

Q1. Using McCulloch Pitts model discussed in the class, write a Python code to imple-
ment the OR and AND Boolean functions. Also, plot the boundary input points and the
linear classifier that we get in that case.

Q2. Write a Python code to implement the Perceptron Learning Algorithm to implement
OR, AND, NAND, NOR logic Gates and report the weights and bias. Also, print the inputs
and outputs after training the weights properly. Further plot the linear classifier that you
have obtained as well. Note that here the input vectors x should be extended with a x0 term,
which is taken as 1. Assume we have two inputs x1 and x2 so the x vector would be [1, x1 , x2 ]

Perceptron training algorithm

Algorithm 1 Perceptron Learning Algorithm


P ← inputs with label 1
N ← inputs with label 0
Initialize w = [w0 , w1 , . . . , wn ] randomly
while !convergence do
Pick random xP ∈P ∪N
if x ∈ P and ni=0 wi · xi < 0 then
w =w+x
end if
if x ∈ N and ni=0 wi · xi ≥ 0 then
P
w =w−x
end if
end while
The algorithm converges when all the inputs are correctly classified.

1
Q3. Next we will see how we can implement an XOR function using inbuild tools. Here

Figure 1: Enter Caption

you can see that we use these tools Keras and tensorflow, developed by Google. Sequential
is a class that can be used to build deep neural networks. Here in the code the model is
an object of the class sequential. We can add new layers in the neural network. the first
hidden layer you see contains 4 neurons and the input dimension is also specified. In our
case we have a 2-dimensional vector as input. We do not represent a separate input layer
here. We are having an output layer with one neuron here. This outputs the probability that
the input vector belongs to a particular class. So after compiling the model and fitting the
model when we go for the predictions here we are getting nothing but the probability that
the input belongs to class 1. If we get a value less than 0.5 we will have a prediction that
the input belongs to class 0 and otherwise to class 1.

You might also like