DEEP LEARNING AND ITS APPLICATION LAB MANUAL
EXPERIMENT 1
OBJECTIVE: Build a deep neural network model start with linear regression using
a) Single variable
b) Multiple variables
EXPLANATION:
a) Single Variable Linear Regression
OUTPUT:
b) Multiple Variables Linear Regression
Build a deep neural network model start with linear regression using multiple variables.
OUTPUT
EXPERIMENT 2: Write a program to convert:
a) Speech into text
b) Text into speech
c) Video into frames
EXPLANATION: The three Python programs that perform the tasks are:
a) Convert Speech to Text
We will use the speech_recognition library to convert speech into text.
Install the library:
Program:
b) Convert Text to Speech
For converting text to speech, we will use the pyttsx3 library. It works offline and supports
multiple speech engines.
Install the library:
Program:
c) Convert Video into Frames
To extract frames from a video, use the opencv-python library.
Install the library:
Program:
OUTPUT:
EXPERIMENT 3: Build a feed forward neural network for prediction of logic gates.
1. Logic Gates Data
AND Gate:
Input1 Input2 Output
0 0 0
0 1 0
1 0 0
1 1 1
OR Gate:
Input1 Input2 Output
0 0 0
0 1 1
1 0 1
1 1 1
XOR Gate:
Input1 Input2 Output
0 0 0
Input1 Input2 Output
0 1 1
1 0 1
1 1 0
2. Implementation of the Feed-Forward Neural Network
Use the Keras library to build the neural network. The network will have an input layer (2
neurons for the 2 inputs), one hidden layer (2 neurons), and an output layer (1 neuron for the
output).
Steps:
1. Prepare the data for each logic gate.
2. Create the feed-forward neural network model.
3. Compile and train the model.
4. Evaluate and make predictions.
3. Python Code Implementation
Install the required libraries:
Program for a Feed-Forward Neural Network:
Output
EXPERIMENT 4: Write a program for character recognition using:
a) CNN
b) RNN
EXPLANATION:
a) Character Recognition using CNN
We'll build a CNN for recognizing characters in images using the MNIST dataset. The
MNIST dataset is often used for digit recognition tasks, but we can apply a similar approach
for character recognition.
Steps:
1. Load the MNIST dataset.
2. Build a CNN model.
3. Train the model.
4. Evaluate the model.
Program for CNN-based Character Recognition (using Keras)
Output for CNN:
b) Character Recognition using RNN (LSTM)
Now, let's use an RNN with LSTM (Long Short-Term Memory) layers for the same task.
While RNNs aren't typically used for image recognition.
Program for RNN-based Character Recognition (using Keras)
Output for RNN (LSTM):
EXPERIMENT 5: Write a program to predict a caption for a sample image using :
a) LSTM
b) CNN
EXPLANATION: The approach into two main parts:
1. Using CNN for feature extraction (for the image).
2. Using LSTM to generate the caption based on the features.
a) Caption Prediction using CNN + LSTM
In this approach, we first use a pre-trained CNN (such as InceptionV3, ResNet, etc.) to
extract features from the image, and then use an LSTM to generate a caption based on these
features.
Steps:
1. Extract features from the image using a CNN.
2. Feed the extracted features to the LSTM to generate a sequence of words (caption).
Code for CNN + LSTM based Caption Generation:
Output:
Predicted Caption:
Pure joy: a dog and its favorite ball.
b) Caption Prediction using CNN (only)
In some cases, we may just use the CNN model for feature extraction (without LSTM) and
display the result in some manner. However, generating a full caption is almost always done
with a combination of CNN + RNN (LSTM/GRU).
Output for CNN-LSTM Model:
Predicted Caption: a dog is playing with a ball
EXPERIMENT 6: Write a program to develop:
a) Auto encoders using MNIST Handwritten Digits.
b) GAN for Generating MNIST Handwritten Digits.
EXPLANATION:
a) Autoencoder for MNIST Handwritten Digits
An Autoencoder is a type of neural network that learns to compress the input (encoding) and
then reconstruct it (decoding). It is commonly used for unsupervised learning tasks like
dimensionality reduction or anomaly detection.
Steps:
1. Build an Encoder to compress the image data.
2. Build a Decoder to reconstruct the data back into the original shape.
3. Train the model using MNIST data.
4. Evaluate and visualize the output.
Code for Auto-encoder on MNIST Handwritten Digits:
Output for Auto-encoder:
b) GAN for Generating MNIST Handwritten Digits
A Generative Adversarial Network (GAN) consists of two neural networks:
1. Generator: Generates fake images.
2. Discriminator: Distinguishes between real and fake images.
The generator tries to create images that resemble the real MNIST digits, and the
discriminator tries to correctly identify whether the images are real or fake.
Code for GAN to Generate MNIST Digits:
Output for GAN:
Additional techniques like advanced architectures, data augmentation, and hyper parameter
tuning would be necessary to improve performance.