NNDL Assignment-2 Report
NNDL Assignment-2 Report
AN ASSIGNMENT-PROJECT REPORT
ON
“Forward Propagation for Convolutional Neural Network”
Submitted in partial fulfilment of the requirements for the award of the
Degree
of
BACHELOR OF TECHNOLOGY
IN
Artificial Intelligence and Data Science
Submitted by
Shreyas (SRN: R21EH166)
Yashas Kishore (SRN: R21EH179)
Vani Luthra (SRN: R21EH181)
Under the guidance of
Prof. Ms. Madhumitha Mishra
REVA University
Rukmini Knowledge Park, Kattigenahalli, Yelahanka,Bengaluru-560064
www.reva.edu.in
i
DECLARATION
We, students of B.Tech., VI Semester, School of Computer Science and Engineering, REVA
University declare that the Assignment-Project Report entitled “Forward Propagation for
Convolutional Neural Network” done by us, School of Computer Science and Engineering,
REVA University.
We are submitting the Assignment-Project Report in partial fulfillment of the requirements for the
award of the degree of Bachelor of Technology in Artificial Intelligence and Data Science by the
ii
Abstract
This outlines a systematic approach to train and evaluate a Convolutional Neural Network (CNN)
model using TensorFlow and Keras with the MNIST dataset. It covers importing libraries, defining
the CNN model architecture, loading, and preprocessing the dataset, and evaluating the model's
accuracy on test data. Key steps include exploratory analysis, visualization of sample images, data
normalization, reshaping for CNN compatibility, and assessing class distribution for balanced
training. The concise description underscores the structured workflow for developing and
accessing CNN models for image classification tasks.
Problem Statement
Develop a CNN-based model that can accurately classify handwritten digits (0-9) from input
images, by efficiently learning relevant features through the forward propagation of the input data
through the network's layers.
Implement the forward_propagation function below to build the following model: CONV2D ->
RELU -> MAXPOOL -> CONV2D -> RELU -> MAXPOOL -> FLATTEN->
FULLYCONNECTED
Problem Description:
This forward propagation function is the core of the CNN-based handwritten digit recognition
model, where the input image is transformed through a series of convolutional, activation, pooling,
and fully connected layers to produce the final digit classification.
iii
Possible Applications:
This is majorly used in the following areas: Image Classification, Object Detection, Image
Segmentation, Video Analysis, Natural Language Processing (NLP), Medical Imaging,
Autonomous Vehicles.
Tech-Innovations:
Mastering forward propagation in CNNs enables the creation of more sophisticated architectures
and optimization techniques, fostering innovation in AI systems.
Significance:
Implementing forward propagation for CNNs provides practical insights into feature extraction,
down sampling, and classification, crucial for effective CNN design and training.
Literature Survey
The research paper "Latent Log-Linear Models for Handwritten Digit Classification" uses the
USPS and MNIST datasets for handwritten digit classification, evaluating Gaussian mixture
models (GMMs) and latent log-linear models (LLMMs)[1]. The USPS dataset contains 7,291
training and 2,007 test observations with 16x16 pixel images, while the MNIST dataset has 60,000
training and 10,000 test observations with 28x28 pixel images. The methodology trains and tunes
models on the USPS dataset, investigates settings, transfers tuned settings to the MNIST dataset,
and experiments with deformation-aware log-linear models on the USPS dataset. Limitations
include model complexity, computational requirements, and generalization to other datasets. To
address these issues, a CNN architecture is proposed with improved classification accuracy,
handling of spatial variability, exceptional generalization across datasets, and scalability through
hardware and software optimization techniques.
iv
Dataset
The dataset which is used is MNSIT which is a large database of handwritten digits that
is commonly used for training various image processing systems.
The MNIST database contains 60,000 training images and 10,000 testing images. Half of
the training set and half of the test set were taken from NIST's training dataset, while the other half
of the training set and the other half of the test set were taken from NIST's testing dataset
Methodology
For training and evaluating a Convolutional Neural Network (CNN) model using TensorFlow
and Keras with the MNIST dataset. It starts with importing necessary libraries and defining a
CNN-Model class, encapsulating the model architecture and training process. The MNIST dataset
is loaded and preprocessed, then used to train the CNN model. Finally, the trained model is
evaluated on the test data, and its accuracy is reported. This streamlined approach ensures a
systematic workflow for developing and accessing CNN models for image classification tasks.
Exploratory Analysis
1. To start the exploratory analysis, we first load the MNIST dataset using
the tensorflow.keras.datasets.mnist.load_data() function, which provides the training and test
sets.
2. Next, we visualize a few sample images from the dataset to get a sense of the data. This is done
by displaying 9 random images from the training set, along with their corresponding labels.
3. During the data preprocessing step, we normalize the pixel values to the range [0, 1] to improve
the model's performance. Additionally, we reshape the input data to fit the Convolutional Neural
Network (CNN) architecture.
4. To further understand the dataset, we examine the class distribution by counting the number
of samples for each digit (0-9) in both the training and test sets. This helps us assess the balance
of the classes, which is an important consideration for the model's training.
5. The MNIST dataset consists of 28x28 pixel grayscale images of handwritten digits (0-9).
6. The training set has 60,000 images, and the test set has 10,000 images.
7. The pixel values are normalized to the range [0, 1] for better model performance.
9. The class distribution is relatively balanced, with each digit having a similar number of
samples in both the training and test sets.
v
Expected Outcome
1. Visualization of Sample Images:
1. The analysis should display 9 random handwritten digit images from the training set,
along with their corresponding labels.
2. This will give you a visual understanding of the data and the challenges involved in
recognizing handwritten digits.
2. Normalization of Pixel Values:
1. The pixel values of the input images should be normalized to the range [0, 1].
2. This is a common preprocessing step that helps improve the model's performance by
ensuring that the input features are on a similar scale.
3. Reshaping of Input Data:
1. The input data should be reshaped to fit the Convolutional Neural Network (CNN)
architecture.
2. For the given problem, the input data should have a shape of (batch_size, 28, 28, 1),
where the last dimension represents the single channel (grayscale) of the images.
4. Class Distribution Analysis:
1. The analysis should provide the number of samples for each digit (0-9) in both the
training and test sets.
2. This information is crucial for understanding the balance of the classes, which can
impact the model's performance and help you determine if any data augmentation or
class weighting is necessary.
5. Insights for Model Development:
1. The exploratory analysis should give you a solid understanding of the MNIST dataset,
including the data characteristics, preprocessing requirements, and the class
distribution.
2. This information will be valuable when designing and training the CNN-based
handwritten digit recognition model, as it will help you make informed decisions about
the model architecture, hyperparameters, and training strategies.
vi
Output
vii