DSE_3141_Deep_Learning_Lab_Manual_2024_Week4
DSE_3141_Deep_Learning_Lab_Manual_2024_Week4
LABORATORY MANUAL
Instructors:
Dr. Rohini R Rao,
Dr. Abhilash K Pai,
Dr. Saraswati Koppad
JULY 2024
COURSE OUTCOMES (COS)
No. of
At the end of this course, the student should be able to: Contact
Marks
Hours
Apply the tools, on different dataset types, do performance
evaluation methods, and fine-tuning strategies to build and
CO1 6 15
optimize vanilla deep neural network models for performing
classification and regression on structured data.
Design, develop, fine-tune, evaluate simple and advanced CNN
CO2 9 35
models for Image classification.
Total 36 100
ASSESSMENT PLAN
Components Continuous Evaluation End semester Examination
Duration 2.5 Hours per week 180 Minutes
Week 4 Advanced CNN Architectures and Transfer Learning for Image CO2
Classification
SL.No References
1 Aurelien Geron, “Hands-On Machine Learning with Scikit-Learn, Keras & Tensorflow,
OReilly Publications
2 Francois Chollet, “Deep Learning with Python”, Manning Publications Co, 2nd edition
# Define operations
x_squared = tf.square(x) # Square operation
x_squared_times_y = tf.multiply(x_squared, y) # Multiply operation
result = tf.add(x_squared_times_y, tf.add(y, 2)) # Add operation
In Keras, there are two primary ways to create deep learning models: the Sequential API and the
Functional API. Each approach serves a different purpose and offers distinct advantages.
1.5 Sequential API:
The Sequential API is the simplest and most straightforward way to build deep learning models in
Keras. It allows you to create a linear stack of layers, where each layer has exactly one input tensor and
one output tensor. This means that the data flows sequentially through each layer in the order they are
added to the model. The Sequential API is well-suited for simple feedforward neural networks and
other models that have a clear linear flow of data.
Example of Sequential API:
from keras.models import Sequential
from keras.layers import Dense, Input
In this step, you train the model on your training data. You provide the input features (X) and their
corresponding target labels (y) to the model. The model then adjusts its internal parameters (weights)
through an optimization process (usually gradient descent) to minimize the defined loss function.
After the model is trained, you need to evaluate its performance on a separate set of data that it has
never seen before (e.g., a validation set or a test set). This step gives you an indication of how well
the model generalizes to unseen data.
V. Make Predictions:
Once the model is trained and evaluated, you can use it to make predictions on new, unseen data. You
pass the new data to the model, and it will provide predictions based on what it has learned during
training.
# Make predictions
predictions = model.predict(X_new_data)
import numpy as np
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Input
Q1. Using the Iris Flowers Dataset, build and Neural Network with the following specifications to
perform multi-class classification.
• Split the Data into Training: Validation: Testing = 80:10:10
• Number of Hidden Layers = 2, containing 8 Neurons and 4 Neurons
• Use RELU activation function in the hidden layers, choose the optimizer as ADAM and set
learning rate to be equal to 0.1.
Q2. Accurate measurement of body fat is inconvenient/costly, and it is desirable to have easy
methods of predicting Body Fat. Using the given Body Fat dataset, build a Neural Network to
predict body fat. Plot the training and validation performance curves and analyze the performance of
the proposed neural network.
The attributes of the dataset are as follows:
• Density determined from underwater weighing
• Percent body fat from Siri's (1956) equation
• Age (years)
• Weight (lbs)
• Height (inches)
• Neck circumference (cm)
• Chest circumference (cm)
• Abdomen 2 circumference (cm)
• Hip circumference (cm)
• Thigh circumference (cm)
• Knee circumference (cm)
• Ankle circumference (cm)
• Biceps (extended) circumference (cm)
• Forearm circumference (cm)
• Wrist circumference (cm)
Q1. Consider the given dataset for Customer Attrition Analysis (customer_attrition.csv), which
analyzes the customer behaviour to predict the likelihood of customers leaving or discontinuing their
relationship with a business.
The dataset has 14 features which are as follows :
1. Perform the required pre-processing and write comment lines to explain the pre-processing steps.
2. Perform experiments using (70,15,15) split and tabulate the performance in terms of Accuracy,
Precision & Recall for the following experimental setup:
a) Number of Hidden Layers and Number of Units per Layer
Number of Number of
Hidden Layers Units
1 128, 0 ,0
2 128, 64, 0
3 128, 64, 32
b) Epochs (10,20,30)
c) Activation function (Sigmoid, ReLU )
d) Learning rate (0.1, 0.01,0.001)
e) Visualize the training and validation loss against the epochs and comment on optimal
hyperparameters.
Q2. You are provided with the FIFA-19 dataset (fifa19.csv). The objective is to predict the
'Position' of a player using the following features:
• 'Finishing', 'HeadingAccuracy', 'ShortPassing', 'Volleys', 'Dribbling', ‘Curve', 'FKAccuracy',
'LongPassing', 'BallControl', 'Acceleration', 'SprintSpeed', 'Agility', 'Reactions', 'Balance',
'ShotPower', 'Jumping', 'Stamina', 'Strength', 'LongShots', 'Aggression','Interceptions',
'Positioning', 'Vision', 'Penalties', 'Composure', 'Marking', 'StandingTackle', 'SlidingTackle',
'GKDiving', 'GKHandling', 'GKKicking', 'GKPositioning', 'GKReflexes'
1. Goalkeeper: ["GK"]
2. Forward Player: ["ST", "LW", "RW", "LF", "RF", "RS","LS", "CF"]
3. Midfielder Player: ["CM", "RCM", "LCM", "CDM", "RDM", "LDM", "CAM", "LAM",
"RAM", "RM", "LM"]
4. Defender Player: ["CB", "RCB", "LCB", "LWB", "RWB", "LB", "RB"]
1. Perform Data Pre-processing: Pre-process the data by cleaning, normalizing, and encoding
as necessary. Include comment lines to explain each pre-processing step.
2. Perform Model Training and Evaluation after splitting the dataset into training (80%),
validation (10%), and test (10%) sets.
b) For each model, find the best number of epochs by visualizing and analyzing the training
and validation loss against epochs.
c) Evaluate each model's performance using Accuracy, Precision, and Recall metrics.
Display the classification report for the test set and comment on the class-wise
performance.
WEEK-3: CONVOLUTIONAL NEURAL NETWORKS (CNN) VS FULLY
CONNECTED NEURAL NETWORKS FOR IMAGE CLASSIFICATION
1) LeNet-5
2) AlexNet
B) Train, test, and compare the performance of these models on the following datasets:
Train, test, and report the performance of the following PRE-TRAINED IMAGENET models
on the Cats and Dogs Dataset and Face Mask Detection Dataset.
A) VGG-16
B) GoogleNet (InceptionV3)
C) ResNet50
D) EfficientNetB0
E) MobileNetV2