0% found this document useful (0 votes)
143 views

Classifying Hand-Written Digits Using Neural Network

- The document discusses building a neural network model to classify handwritten digits using the MNIST dataset. It describes preprocessing the data, creating a sequential model in Keras, training the model for 3 epochs, and evaluating the model's performance on the test set. The model uses basic neural network architecture with convolutional and dense layers to classify handwritten digits with high accuracy.

Uploaded by

Nihir Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
143 views

Classifying Hand-Written Digits Using Neural Network

- The document discusses building a neural network model to classify handwritten digits using the MNIST dataset. It describes preprocessing the data, creating a sequential model in Keras, training the model for 3 epochs, and evaluating the model's performance on the test set. The model uses basic neural network architecture with convolutional and dense layers to classify handwritten digits with high accuracy.

Uploaded by

Nihir Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 21

A Presentation on

Presented By: Under the guidance of:


•Viranchi Bhure Sandeep S. Ganokar
•Abhinav Masane Department of I.T,
•Ravindra Ghawade K.D.K.C.E,
•Sagar Rokde RTMNU,
•Nihir Yadav Nagpur, India.
•Introduction
•Idea to research
•Methodology
•Proposed Model
•Background Study
•Implementation
•Literature Review
•References
• We will be using basic functionality of Keras with TensorFlow as its backend
and use it to solve a basic image classification problem. We will have
created, trained, and evaluated a Neural Network model that will be able to
predict digits from hand-written images with a high degree of accuracy. We
will also have learned and applied some fundamentals of neural networks,
TensorFlow, and Keras.

Neural Network
Model

Image of a hand- The model predict


written digit the class
• Writing styles varies from one person to another which makes human
written digit recognition a main field for research and practice. Because
of such differentiated style of writing the digits, it becomes a great
difficult task for an individual to go through the digits.
• So, we wonder what circumstances will occur if the computer is
replaced by human. Therefore, the recognition of handwritten digits
done by computer would be difficult as compared to the handwritten
digits by human.
• A proper and diverse database has to be provided to the machine so
that it can get trained and recognize accurately and effectively.
• Hand-written Digit Classification is an interesting machine learning
problem in which we have to identify the handwritten digits through
various classification algorithms.
• There are a number of ways and algorithms to recognize handwritten
digits, including Deep Learning/CNN, SVM, Gaussian Naive Bayes, KNN,
Decision Trees, Random Forests, etc.
• In this project, we will use a Neural Network model to solve the basic
image classification problem.
• Some of the online tools and software libraries used will be Google
Colab, Tensorflow, Keras, Matplotlib, Numpy.
• Step 1: Gather relevant data. We will be using the popular MNIST dataset which has
lots of images of hand-written digits along with their labels.
• Step 3: Pre-processing the data.
• Step 4: Creating the model - using a Sequential class defined in Keras to create our
model.
• Step 4: Training the model - We are going to train the model for 3 epochs.
• Step 5: Evaluating the model - we will evaluate the performance of the trained model
on the test set.
• Step 6: Predictions – We will look at the predicted and actual labels and see how our
trained model actually performed.
Preprocessing
the Data

Creating the
Model
• MNIST is a simple computer vision dataset which consists of different
images labels for each handwritten digit conveying that which digit is.
The data from MNIST dataset which consists of different styled (28 x
28) pixel images. So, our input layer contains 784 input neurons. The
training and test set are different, is necessary for the purpose of
helping the neural network learn from the training dataset only.
Rather than memorizing the entire dataset and then reciprocating the
same, it actually predicts the test set.
• We also the changed the shape of the labels by one hot encoding. It is
a process by which categorical variables are converted into a form
that could be provided to ML algorithms to do a better job in
prediction.
• Before using the images which are in 28*28 pixels, we need to change the
shape of that so that it can be easily fed to the model. For the changing the
shape of the image data which is two dimensional array, we will use numpy’s
reshape function and the new shape for the images will be a single
dimensional array of 784.
• Pixel values, in this dataset, range from 0 to 255. These default values cane be
used if we only want to display our images but for the neural network to learn
the weights and biases for different layers, computations will be more
effective and fast if we normalized these values. In order to normalize the
data, we can calculate the mean and standard deviation for each example.
• We will then normalise both the training and test set using the mean and
standard deviation. One important that we will need to apply the same mean
and standard deviation calculated from training set to the test set.
• Now, the data has been processed, we can start with the model. For creating
the model, we are going to use the sequential class of the Keras package. We
will have to specify the number of the layers, how many nodes, layers will be
dense or not, type of activation use, etc.
• After the declaring the model’s structure we can compile it using the compile
function. Parameters such as loss, optimizing algorithm which is to be used
are specified here. We can also set which metrics we want to see. One metric
commonly used is “accuracy”.
• Now, we can train the model use the fit function. It takes the training dataset,
training labels and numbers of epochs as it’s parameter. Epoch is like an
iteration of all the examples going through the model.
• In order to ensure that this is not a simple memorization of the training
dataset by the machine, we will evaluate the performance of the model on
the test set. We simply use the evaluate method on the model. This function
will return the accuracy and the loss value.
• We will then plot the few test set images along with their predicted and
actual labels and see how our trained model actually performed.
• We will also look at the probability scores for some individual digit sample
that the model predicted wrong class.
b b b

X1 w w w
n1 n1 n1
w

...........

...........
...........

...........
w y
w w
w
X784 w n128 w
w n128 n10

Single node/neuron : n = W.X + b


Softmax Activation Function: e^x / sum(e^x)
Relu Activation Function: f(x)=max(0,x)
•Softmax Function (Genralized Sigmoid Function) :
•The output is always in the range zero to one. This function will give us probability
scores for various nodes, in our case 10 nodes of the output layer, which sum upto 1.
This activation gives us the probabilities for various classes given the input. The class
with the highest probability gives us our prediction.
•ReLU (Rectified Linear Unit) :
•It’s a pretty simple function: it’s a linear function for all the positive values and is
simply set to 0 for all the negative values. As the range is from one to infinity, most
activation are fired but ideally we would like to only few neurons to fire. So this
function can increase computational cost.
•The framework is implemented in Google Colab.
•Data imported from MNIST have been encoded , reshaped and normalized. The
visualization were used to look at the dataset and later on predictions and probability
scores.
•Software required :
•No particular software was used. Rather the code has been setup in Google Colab
(which can be accessed via any browser).
•Hardware Required:
•CPU 64 bit 2.8 GHz
•RAM 4 GB (minimum)
•Fathma Siddique; Shadman Sakib; Md. Abu Bakr Siddique (2019) “Recognition of
Handwritten Digit using Convolutional Neural Network in Python with Tensorflow and
Comparison of Performance for Various Hidden Layers” in 5th International Conference
on Advances in Electrical Engineering (ICAEE), 26-28 Sept. 2019 , Dhaka, Bangladesh.
•Tanya Makkar; Yogesh Kumar; Ashwani Kr Dubey; Álvaro Rocha; Ayush Goyal (2017)
“Analogizing time complexity of KNN and CNN in recognizing handwritten digits” in
Fourth International Conference on Image Information Processing (ICIIP), 21-23 Dec.
2017, Shimla, India.
•Mayank Jain; Gagandeep Kaur; Muhammad Parvez Quamar; Harshit Gupta (2021)
“Handwritten Digit Recognition Using CNN” in International Conference on Innovative
Practices in Technology and Management (ICIPTM), 17-19 Feb. 2021, Noida, India.
•Shifeng Huang (2020) “Influence of Different Convolutional Neural Network Settings on
the Performance of MNIST Handwritten Digits Recognition” in IEEE International
Conference on Advances in Electrical Engineering and Computer Applications( AEECA),
26-28 June 2020, Tianjin, China
•Tanya Makkar; Yogesh, Kumar, Ashwani Kr Dubey, Álvaro Rocha; Ayush Goyal [1] :
“Analogizing Time Complexity of KNN and CNN in Recognizing Handwritten Digits”. The
paper used different parameters such as error rate, accuracy to compare the
performance of two different algorithms that tackle a basic image classification problem.

•Fathma Siddique, Shadman Sakib, Md. Abu Bakr Siddique [2] : “Recognition of


Handwritten Digit using Convolutional Neural Network in Python with Tensorflow and
Comparison of Performance for Various Hidden Layers”. The goal of this paper was to
review the performance of the same algorithm when applied to a basic image
classification problem. The accuracy of the algorithm was compared by changing the
numbers of hidden layers, numbers of iteration i.e. epochs.
•Mayank Jain, Gagandeep Kaur, Muhammad Parvez Quamar, Harshit Gupta [3] :
“Handwritten Digit Recognition Using CNN”. The paper studies the and demonstrate that
convolutional neural network can give better performance over neural network.

•Shifeng Huang [4] : “Influence of Different Convolutional Neural Network Settings on the
Performance of MNIST Handwritten Digits Recognition”. The project use convolutional
neural network to classify hand-written digits. It uses Tensorflow as backend and
parameters such as iterations, hidden layers were tuned to check how it affects accuracy.
•The model was trained and evaluated against an unknown dataset. It showed greater
accuracy even if the number of layers, epochs were low. We can achieve greater
accuracy but it can lead to overfitting of the model. Overfitting negatively affect the
model as it means the model will memorize the noise of the data and it will not
recognize unknown data properly.
•As MNIST dataset is used in other Machine Learning and Deep learning problems such
as Object Detection, Image Classification. We can apply the knowledge gained by tackling
the Digit Classification problem to other ML, DL problem.
•The accuracy can be manipulated i.e increased or decreased by parameter tuning.
Parameter tuning includes choosing number of layers, which activation function to use,
number of epochs, which optimizer to use, etc.

You might also like