0% found this document useful (0 votes)
15 views55 pages

1822 B.E Ece Batchno 14

The document discusses building a model to classify handwritten digits using a convolutional neural network. It describes capturing images, preprocessing the data, dividing it into training and testing sets, building a CNN model using TensorFlow and Keras libraries, making predictions on test data, and achieving an accuracy of 92.5%.

Uploaded by

guru yo
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)
15 views55 pages

1822 B.E Ece Batchno 14

The document discusses building a model to classify handwritten digits using a convolutional neural network. It describes capturing images, preprocessing the data, dividing it into training and testing sets, building a CNN model using TensorFlow and Keras libraries, making predictions on test data, and achieving an accuracy of 92.5%.

Uploaded by

guru yo
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/ 55

HANDWRITTEN DIGITS CLASSIFICATION WITH

CONVOLUTION NEURAL NETWORK


Submitted in partial fulfilment of the requirements for the award of
Bachelor of Engineering degree in Electronics and Communication Engineering.

by

KOLLUKULURU SAI THARUN (38130108)


K.SUDHEER KUMAR REDDY (38130103)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


SCHOOL OF ELECTRICAL AND ELECTRONICS ENGINEERING

SATHYABAMA
INSTITUTE OF SCIENCE AND TECHNOLOGY
(DEEMED TO BE UNIVERSITY)
Accredited with Grade “A” by NAAC
JEPPIAAR NAGAR, RAJIV GANDHI SALAI, CHENNAI - 600 119

MAY - 2022
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

BONAFIDE CERTIFICATE

This is to certify that this Project Report is the bonafide work of KOLLUKULURU SAI
THARUN(38130108),K.SUDHEER KUMAR REDDY(38130103) who carried out the
project entitled “HANDWRITTEN DIGITS CLASSIFICATION WITH CONVOLUTION
NEURAL NETWORK(CNN)” under our supervision from August, 2021 to May, 2022.

Internal Guide
Dr.M.R.EBENEZAR JEBARANI M.E.,Ph.D.,

Head of the Department


Dr.T.RAVI M.E.,Ph.D.,

____________________________________________________________
Submitted for Viva voce Examination held on ____________________

Internal Examiner External Examiner


DECLARATION

We KOLLUKULURU SAI THARUN (38130108) , K.SUDHEER KUMAR REDDY


(38130103) , hereby declare that the Project Report entitled “HANDWRITTEN DIGITS
CLASSIFICATION WITH CONVOLUTION NEURAL NETWORK (CNN)” done by us
under the guidance of Dr. M.R.EBENEZAR JEBARANI M.E., Ph.D., at SATHYABAMA
INSTITUTE OF SCIENCE ANDTECHNOLOGY is submitted in partial fulfilment of the
requirements for the award of Bachelor of Technology degree in Electronics and

communication Engineering.

DATE : 1.

PLACE: 2.

SIGNATURE OF THE CANDIDATES


ACKNOWLEDGEMENT

We are pleased to acknowledge my sincere thanks to the Board of Management


of SATHYABAMA for their kind encouragement in doing this project and for
completing it successfully. We are grateful to them.

We convey our thanks to Dr.N.M.NANDHITHA, M.E.,Ph.D., Professor & Dean of


school of Electrical and Electronics and Dr.T.RAVI, M.E.,Ph.D., Head of the
Department, Department of Electronics and communication Engineering for
providing us necessary support and details at the right time during the
progressive reviews.

We would like to express our sincere and deep sense of gratitude to our Project
Guide Dr.M.R.EBENEZAR JEBARANI, M.E.,Ph.D., for her valuable guidance,
suggestions and constant encouragement paved the way for the successful
completion of our project work

We would like to express our sincere and deep sense of gratitude to our Project
panel members Dr.S.EMALDA ROSLIN, Dr.N.R.KRISHNAMOORTHY for their
valuable guidance, suggestions and constant encouragement paved the way for
the successful completion of our project work.

We wish to express our thanks to all Teaching and Non-teaching staff and also
panel members of the Department of Electronics and Communication
Engineering who were helpful in many ways for the completion of the project.
ABSTRACT

To build a model which can identify the handwritten digits by Recognition


and classify them. Humans can see and visually sense the world around them by using
their eyes and brains. Computer vision works on enabling computers to see and
process images in the same way that human vision does. Several algorithms developed
in the area of computer vision to recognize images. The goal of our work will be to
create a model that will be able to identify and determine the handwritten digit from its
image with better accuracy. Aim to complete this by using the concepts of Convolutional
Neural Network. Through this work, Aim to learn and practically apply the concepts of
Convolutional Neural Networks. Created our own data images of 1000 Images which
are used to train and test.

The issue of transcribed digit acknowledgment has for some time been an
open issue in the field of example order. A few examinations have demonstrated that a
Neural Network has an incredible execution in information arrangement. The
fundamental target of this paper is to give effective and solid procedures to
acknowledge transcribed numerical by looking at different existing arrangement models.
This paper is about the exhibition of Convolutional Neural Network (CCN). Results
demonstrate that CNN classifier beat over Neural Network with critical improved
computational effectiveness without relinquishing execution. Handwritten digit
recognition can be performed using the Convolutional neural network from Machine
Learning. Basically to perform the model required some libraries such as NumPy,
Pandas', TensorFlow, Keras.

This discussion is about the Convolutional Neural Network and its importance.
It also covered how a dataset is divided into training and test dataset. A dataset was
taken to make predictions of handwritten digits from 0 to 9. The dataset was cleaned,
scaled, and shaped.Using TensorFlow, a CNN model was created and was eventually
trained on the training dataset. Finally, predictions,classification were made using the
trained model with an accuracy of 92.5%.

(i)
TABLE OF CONTENTS

CHAPTER TITLE PAGE NUMBER

ABSTRACT i

LIST OF FIGURES iv

1 INTRODUCTION 1

1.1 INTRODUCTION OF HANDWRITTEN 1


DIGITS CLASSIFICATION

1.2 PROBLEM STATEMENT & OBJECTIVE 2

2 LITERATURE SURVEY 5

3 EXISTING SYSTEM 8

3.1 SUPPORT VECTOR MACHINE 8

3.2 METHODOLOGY 9

3.3 BLOCK DIAGRAM 11

3.4 ADVANTAGES & DISADVANTAGES 12

4 PROPOSED SYSTEM 13

4.1 CONVOLUTION NEURAL NETWORK 13

4.2 ADVANTAGES 15

4.3 CNN ALGORITHM 15

4.4 BLOCK DIAGRAM & WORKFLOW 16

(ii)
4.6 POOLING 19

4.5 NORMALIZATION 18

4.7 FULLY CONNECTED LAYER 21

4.8 CNN WORKING 22

5 RESULTS AND DISCUSSIONS 26

5.1 CAPTURED IMAGES AND INPUT 26

5.2 CREATE DATA 28

5.3 DIVIDING DATA INTO TRAINING & TESTING 29


PART

5.4 BUILDING THE MODEL 30

5.5 PREVIEW OF IMAGE 32

5.6 PREDICT AND DISPLAY 33

5.7 PREDICTION OF DIGITS 35

5.8 ACCURACY 40

6 CONCLUSION & FUTURE SCOPE 41

REFERENCES 42

(iii)
LIST OF FIGURES

FIGURE TITLE PAGE NUMBER


NUMBER

1.1 Handwritten Digits 4

3.1 SVM Plot 8

3.2 SVM Methodology Code 10

3.3 Confusion Matrix 10

3.4 SVM Block Diagram 11

4.1 CNN WorkFlow 16

4.2 CNN Block Diagram 16

4.3 Layers in CNN 17

4.4 Digit in Pixel View 18

4.5 Pooling 19

4.6 Max & Average Pooling 20

4.7 Fully Connected Layer Block Diagram 21

4.8 Three Colour Channels 22

4.9 Kernel View 23

4.10 Convolved Feature 24

4.11 Kernel Channel 25

(iv)
5.1 Captured Images 26

5.2 Captured Image function code 27

5.3 Create Data Code 28

5.4 Create Function 29

5.5 Data Dividing Code 29

5.6 Importing Necessary Python Libraries 30

5.7 Executing Epoch 31

5.8 Preview of Image 32

5.9 Creating Test Data 33

5.10 Digits Classification 33

5.11 Image Prediction Code 34

5.12 Prediction of Digit 0 35

5.13 Prediction of Digit 1 36

5.14 Prediction of Digit 2 36

5.15 Prediction of Digit 3 37

5.16 Prediction of Digit 4 37

5.17 Prediction of Digit 5 38

5.18 Prediction of Digit 6 38

(v)
5.19 Prediction of Digit 7 39

5.20 Prediction of Digit 8 39

5.21 Prediction of Digit 9 40

5.22 Accuracy 40

(vi)
CHAPTER - 1

INTRODUCTION

1.1 INTRODUCTION OF HANDWRITTEN DIGITS CLASSIFICATION

Crane's early work culminated in a first patent in 1964 for a special pen device.
These initial efforts took a more advanced form in the early 1970s with a system that
used what was generally referred to as the “SRI pen” as a method of inputting
characters into a computer. Commercial products incorporating handwriting recognition
as a replacement for keyboard input were introduced in the early 1980s.

In the current age of digitization, handwriting recognition plays an important role


in information processing. There is a lot of information available on paper and less
processing of digital files than the processing of traditional paper files. The purpose of
the handwriting recognition system is to convert handwritten letters into
machine-readable formats. Major applications include vehicle licence-plate
identification, postal paper-sorting services, historical document preservation in the
check truncation system (CTS) scanning and archaeology departments, old document
automation in libraries and banks, and more.

All of these areas deal with large databases and therefore require high
identification accuracy, low computational complexity, and consistent performance of the
identification system. Over time, the number of fields that can implement deep learning
is increasing. In deep learning, convolutional neural networks (CNN) are being used for
visual image analysis. CNN can be used in object detection, facial recognition, robotics,
video analysis, segmentation, pattern recognition, natural language processing, spam
detection, topical gradation, regression analysis, speech recognition, image
classification.

1
Detection of handwritten numbers, including accuracy in these areas, has
reached human perfection using deep convolutional neural networks (CNNs). Recently
CNN has become one of the most attractive approaches and has been the ultimate
factor in recent success and in several challenging machine learning applications.
Considering all the factors stated above have chosen CNN for our challenging tasks of
image classification.Used it to identify handwritten numbers, which is one of the higher
education and business transactions. There are many applications of handwritten digit
recognition for our real-life purposes. Hence using the Convolutional Neural Network
(CNN).

1.2 PROBLEM STATEMENT & OBJECTIVE

Handwriting recognition has been the main subject of research for almost the last
forty years. This research work analyzes the behaviour of classification techniques
(CNN) in a large handwriting dataset to predict a digit. Machine-learning techniques,
particularly when applied to Neural Networks like CNN or ANN, have played an
increasingly important role in the design of these recognition systems.

Several methods have been developed in handwritten digit recognition and these
methods have been classified into categories: knowledge-based methods,
feature-based methods, template-based methods and appearance-based methods.
Errors in Digit recognition cause severe problems like digits written on a bank cheque if
recognized erroneously could result in unfortunate consequences.

The goal of our work is to create a model that will be able to recognize and classify
the handwritten digits from images by using concepts of Convolution Neural Network.
Though the goal of our research is to create a model for digit recognition and
classification, it can also be extended to letters and an individual’s handwriting. The
major goal of the proposed system is understanding Convolutional Neural Network, and
applying it to the handwritten digit recognition system by working on the dataset
created.

2
There have already been significant advancements in this area previously.Tried to
form a model around the Conventional Neural Network as our own dataset so that the
model has high accuracy and has been trained and tested on a large dataset.Also
consider developing a robust test harness for estimating the performance of the model
and then exploring improvements to the model. With high accuracy rates, the model can
solve a lot of real life problems.In the field of digital image processing, pattern
recognition is the research area that studies the operation and design of systems that
recognize patterns in data. Its primary goal is the classification of objects into a number
of categories or classes. Depending on the use, these objects can be images, signal
waveforms or any other type of measurements that need to be classified. Common
applications of pattern recognition are automatic speech recognition, classification of
text into several categories (e.g. spam/non-spam email messages) and the automatic
recognition of handwritten postal codes on postal envelopes. Statistical approaches are
one of the most widely studied and used to perform pattern classification. In statistical
pattern recognition, an image is represented by a set of f features which constitute a
f-dimensional feature vector. A decision process (statistical classifier) based on this
vector is used to establish boundaries between image classes and then perform the
classification. Thus, the classification success depends entirely on the set of selected
features and the classification scheme.

A human brain can easily interpret a sophisticated image and can extract data from
it, but for a computer, an image is a collection of pixels which are nothing but a list of
combinations of numbers ranging from 0 to 255, blends being RGB, B.W., greyscale,
etc. Information in an image can be extracted from the pixel values. A human eye
contains light-sensitive cells that can segment the image into partitions which help to
interpret the information like shape, size, and colour which are called features, these
features are later sent to the visual cortex that analyses the characteristics and maps it
to our memory for identification. Thus our brain is capable of identifying an unseen
image.

3
Fig 1.1 : Handwritten Digits

Fig 1.1 shows Different Handwritten Digits from Digit 0 to 9.

4
CHAPTER - 2

LITERATURE SURVEY

Ahamed Hafiz (2018) developed a Support Vector Machine SVM Based Real
Time HandWritten Digits Classification using Support vector Machine but it is Not
suitable for Large Data sets.

Anuj Dutt (2017) proposed a Handwritten Digits Classification with Back


Propagation Network.Backpropagation is the essence of neural network training. It is
the method of fine-tuning the weights of a neural network based on the error rate
obtained in the previous epoch.But it is less Efficient. By utilising the convolutional
Neural Network with Keras and Theano as backend.

Denker J.S (2019) implemented Handwritten Digits Recognition to reduce the


error rate as much as possible in handwriting recognition. In one research, an error rate
of 1.19% is achieved using 3-NN trained and tested on MNIST Coherence recurrent
convolutional network (CRCN) is a multimodal neural architecture.It is being used in
recovering sentences in an image. Some researchers are trying to come up with new
techniques to avoid drawbacks of traditional convolutional layers. NCFM (No
combination of feature maps) is a technique which can be applied for better
performance using MNIST datasets.

Haider (2020) developed a new challenging digit Arabic dataset collected from
different study levels of schools. A large dataset is collected after paying vast effort for
distributing and collecting digit forms over hundreds of primary, high, college students.
After he found that there were few and not challenging Arabic digit dataset, He paid vast
effort for preparing such a challenging dataset.

5
Mukesh N (2018) implemented a Classification of Handwritten Characters Using
k-means clustering Machine Learning Algorithms But it is Not suitable for Large Data
sets and it has low accuracy and High Baseline Error.

Nitin Kali Raman (2021) proposed a Handwritten Digit Recognition using Artificial
Neural Network.An ANN is based on a collection of connected units or nodes called
artificial neurons, which loosely model the neurons in a biological brain. Each
connection, like the synapses in a biological brain, can transmit a signal to other
neurons. An artificial neuron receives a signal then processes it and can signal neurons
connected to it.But he got a High Baseline Error.

Plamondon, R (2018) developed a Handwritten digits recognition and dataset that


has been trained on artificial neural networks and on convolutional neural networks. The
average error of both networks was calculated using the accuracy evaluation metric.
The average error of CNN is less than an artificial neural network on the CPU. Though
while training CNN over CPU took more time than artificial neural network. But image
classification is better performed in the case of CNN. It can be concluded that as the
model is trained with CNN, the accuracy of recognition increases respectively but if
trained on GPU can get optimum results for the classification with CNN.

Saeed Mansoori (2020) proposed a Multilayer Perceptron (MLP) Neural Network


to recognize and predict handwritten digits from 0 to 9.A multilayer perceptron (MLP) is
a fully connected class of feedforward artificial neural network (ANN). The term MLP is
used ambiguously, sometimes loosely to mean any feedforward ANN, sometimes strictly
to refer to networks composed of multiple layers of perceptrons (with threshold
activation).The proposed neural system was trained and tested on a dataset achieved
from MNIST.

Shamim S.M (2018) introduced Handwritten Digit Recognition using Machine


Learning Algorithms using Gaussian Naive Bayes.Gaussian Naive Bayes is a variant of

6
Naive Bayes that follows Gaussian normal distribution and supports continuous
data.The drawback of this is Low accuracy.

Shyam R (2017) implemented Handwritten Digits Classification using MNIST


dataset that deep nets perform better when they are trained by simple
back-propagation.But,Their architecture results in the lowest error rate on MNIST
compared to NORB and CIFAR10.

Sonia flora (2016) developed a Handwritten Digits Classification using support


vector machine(SVM).support vector machine is supervised learning models with
associated learning algorithms that analyze data for classification and regression
analysis.But got less accuracy compared to convolution neural network(CNN).since it is
a large dataset it gives less accuracy.

Vinjit B.M (2020) implemented Handwritten Character Recognition Methods and


Techniques Using keras with Theano and Tensorflow gives the lowest accuracy in
comparison with the most widely used machine learning algorithms Because of its
lowest accuracy, Convolutional Neural Network (CNN) is being used on a large scale in
image classification, video analysis, etc.

7
CHAPTER - 3

EXISTING SYSTEM

3.1 SUPPORT VECTOR MACHINE

“Support Vector Machine” (SVM) is a supervised machine learning algorithm


that can be used for both classification or regression challenges. However, it is mostly
used in classification problems. In the SVM algorithm, plot each data item as a point in
n-dimensional space (where n is a number of features you have) with the value of each
feature being the value of a particular coordinate. Then performed classification by
finding the hyper-plane that differentiates the two classes very well (look at the below
shown figure)

Fig 3.1 : SVM Plot

Fig 3.1 depicts Support Vector Machine Plot with different support vectors along x-axis
and y-axis.

8
Support Vectors are simply the coordinates of individual observation. The SVM
classifier is a frontier that best segregates the two classes (hyper-plane/ line).
At support vector machines and a few examples of their working here.All values for z
would be positive always because z is the squared sum of both x and y
In the original plot, red circles appear close to the origin of x and y axes, leading to
lower value of z and stars relatively away from the origin result in higher value of z.

Support Vector Machine (SVM) is a supervised machine learning algorithm. In this


generally plot data items in n-dimensional space where n is the number of features, a
particular coordinate represents the value of a feature performing the classification by
finding the hyperplane that distinguishes the two classes.It will choose the hyperplane
that separates the classes correctly. SVM chooses the extreme vectors that help in
creating the hyperplane. These extreme cases are called support vectors, and hence
the algorithm is termed as SupportVector Machine. There are mainly two types of
SVMs, linear and non-linear SVM.Linear SVM for handwritten digit recognition.

3.2 METHODOLOGY

SVM is capable of doing both classification and regression. In this post I'll focus
on using SVM for classification. In particular I'll be focusing on non-linear SVM, or SVM
using a non-linear kernel. Non-linear SVM means that the boundary that the algorithm
calculates doesn't have to be a straight line. The benefit is that you can capture much
more complex relationships between your data points without having to perform difficult
transformations on your own. The downside is that the training time is much longer as
it's much more computationally intensive.

9
Fig 3.2 : SVM Methodology Code

Fig 3.2 shows Support Vector Machine Methodology code using random,randint
matplotlib.

Fig 3.3 : Confusion Matrix

Fig 3.3 represents Confusion Matrix of Support Vector Machine Confusion Matrix used
for evaluating the performance of a classification model,The matrix compares the actual
target values with those predicted by the machine learning model.

10
3.3 BLOCK DIAGRAM

Fig 3.4 : SVM Block Diagram

Fig 3.4 explains about Support Vector Machine Block Diagram.Collection Digit
Database it will collect Handwritten Digits as images and convert them into a
dataset.preprocessing process the data and it will send to SVM/k-nn classifier using
k-nn classifier Algorithm digits were recognized.

3.4 ADVANTAGES & DISADVANTAGES OF SVM

ADVANTAGES
1)SVM works relatively well when there is a clear margin of
separation between classes.

2)SVM is more effective in high dimensional spaces.

11
3)SVM is effective in cases where the number of dimensions is greater than the number
of samples.

4)SVM is relatively memory efficient

DISADVANTAGES

1)SVM algorithm is not suitable for large data sets.

2)SVM does not perform very well when the data set has more noise i.e. target classes
are overlapping.

3)In cases where the number of features for each data point exceeds the number of
training data samples, the SVM will underperform.

4)As the support vector classifier works by putting data points, above and below the
classifying hyperplane there is no probabilistic explanation for the classification

12
CHAPTER - 4

PROPOSED SYSTEM

4.1 CONVOLUTION NEURAL NETWORK (CNN)

A convolutional neural network (CNN) is a type of artificial neural network used in


image recognition and processing that is specifically designed to process pixel data. A
convolutional neural network consists of an input layer, hidden layers and an output
layer. In any feed-forward neural network, any middle layers are called hidden because
their inputs and outputs are masked by the activation function and final convolution.
In a convolutional neural network, the hidden layers include layers that perform
convolutions. Typically this includes a layer that performs a dot product of the
convolution kernel with the layer's input matrix. This product is usually the Frobenius
inner product, and its activation function is commonly ReLU. As the convolution kernel
slides along the input matrix for the layer, the convolution operation generates a feature
map, which in turn contributes to the input of the next layer. This is followed by other
layers such as pooling layers, fully connected layers, and normalization layers.

Feed Forward neural network and Designed mostly for Image classification
Consists of an Input layer , multiple hidden layers , output layers In deep learning, a
convolutional neural network (CNN/ConvNet) is a class of deep neural networks, most
commonly applied to analyze visual imagery. Now when thinking of a neural network
think about matrix multiplications but that is not the case with ConvNet. It uses a
special technique called Convolution. Now in mathematics convolution is a
mathematical operation on two functions that produces a third function that expresses
how the shape of one is modified by the other. The role of the ConvNet is to reduce the
images into a form that is easier to process, without losing features that are critical for
getting a good prediction.

13
A Convolutional Neural Network (ConvNet/CNN) is a Deep Learning algorithm
which can take in an input image, assign importance (learnable weights and biases) to
various aspects/objects in the image and be able to differentiate one from the other. The
benefit of using CNNs is their ability to develop an internal representation of a
two-dimensional image. This allows the model to learn position and scale invariant
structures in the data, which is important when working with images CNN is mainly used
in image analysis tasks like Image recognition, Object detection & Segmentation CNNs
are powerful image processing, artificial intelligence (AI) that use deep learning to
perform both generative and descriptive tasks, often using machine vision that includes
image and video recognition, along with recommender systems and natural language
processing (NLP) Faster R-CNN is a single-stage model that is trained end-to-end. It
uses a novel region proposal network (RPN) for generating region proposals, which
save time compared to traditional algorithms like Selective Search. It uses the ROI
Pooling layer to extract a fixed-length feature vector from each region
proposal.convolutional neural network (CNN/ConvNet) is a class of deep neural
networks, most commonly applied to analyze visual imagery. Now when thinking of a
neural network think about matrix multiplications but that is not the case with ConvNet.
It uses a special technique called Convolution.In Convolutional neural network, the
kernel is nothing but a filter that is used to extract the features from the images. The
kernel is a matrix that moves over the input data, performs the dot product with the
sub-region of input data, and gets the output as the matrix of dot products.

CNNs are a class of Deep Neural Networks that can recognize and classify
particular features from images and are widely used for analyzing visual images. Their
applications range from image and video recognition, image classification, medical
image analysis, computer vision and natural language processing.Neurons in a
convolutional layer that cover the entire input and look for one feature are called filters.
These filters are 2 dimensional (they cover the entire image). However, having the
whole convolutional layer looking for just one feature (such as a corner) would
massively limit the capacity of your network. The main special technique in CNNs is

14
convolution, where a filter slides over the input and merges the input value + the filter
value on the feature map. In the end, our goal is to feed new images to our CNN so it
can give a probability for the object it thinks it sees or describe an image with text.The
output of the CNN is also a 4D array. Where batch size would be the same as input
batch size but the other 3 dimensions of the image might change depending upon the
values of filter, kernel size, and padding use.2D CNNs use 2D convolutional kernels to
predict the segmentation map for a single slice. Segmentation maps are predicted for a
full volume by taking predictions one slice at a time. The 2D convolutional kernels are
able to leverage context across the height and width of the slice to make predictions.

In any neural network, a dense layer is a layer that is deeply connected with its
preceding layer which means the neurons of the layer are connected to every neuron of
its preceding layer. This layer is the most commonly used layer in artificial neural
network networks.

4.2 ADVANTAGES

1)Very High accuracy in image recognition problems.


2)Automatically detects the important features without any human supervision.
3)Weight sharing.
4)It automatically detects the important features without any human supervision. For
example, given many pictures of cats and dogs it learns distinctive features for each
class by itself.
5)CNN is also computationally efficient.

4.3 CNN ALGORITHM

1)Images(100x100x3 images)
2)Convolution Layer
3)ReLU(Normalization)
4)Max pooling

15
5)Fully connected Output

4.4 BLOCK DIAGRAM & WORKFLOW

Fig 4.1 : CNN WorkFlow


Fig 4.1 represents Convolutional Neural Network workflow.Handwritten Digits Dataset is
created and then Dataset will be trained and tested from training dataset it will go to cnn
model.Test dataset is sent to Trained cnn model from that digits were classified and
predicted.

Fig 4.2 : CNN Block Diagram

16
Fig 4.2 shows CNN Block Diagram.From 28 x 28 pixel Image using convolution and
max pooling and relu techniques images are predicted and classified.

Fig 4.3 : Layers in CNN

Fig 4.3 depicts layers in CNN.From input image with 28x28x1 pixel modified into
different layers and channels as shown in the above figure.

17
Fig 4.4 : Digit in pixel view

Fig 4.4 indicates Digit in pixel view.It is showing pixel values in black region and zeroes
in white region.Based on this images are identified.

4.5 NORMALIZATION

ReLU(Rectified Linear Units) Activation Function The main reason ReLU is


used is because it is simple, fast, and empirically it seems to work well. The usage of
ReLU helps to prevent the exponential growth in the computation required to operate
the neural network. If the CNN scales in size, the computational cost of adding extra
ReLUs increases linearly. The rectified linear activation function, or ReLU activation
function, is perhaps the most common function used for hidden layers. It is common
because it is both simple to implement and effective at overcoming the limitations of
other previously popular activation functions, such as Sigmoid and Tanh.

18
4.6 POOLING

Reduces the Dimension of matrix Max pooling,Min pooling,Average pooling


Max pooling is mostly used Similar to the Convolutional Layer, the Pooling layer is
responsible for reducing the spatial size of the Convolved Feature. This is to decrease
the computational power required to process the data through dimensionality reduction.
Furthermore, it is useful for extracting dominant features which are rotational and
positional invariant, thus maintaining the process of effectively training the model.
There are two types of Pooling: Max Pooling and Average Pooling. Max Pooling returns
the maximum value from the portion of the image covered by the Kernel. On the other
hand, Average Pooling returns the average of all the values from the portion of the
image covered by the Kernel.

Fig 4.5 : Pooling

Fig 4.5 shows pooling.From convolution matrix it converts and takes as 5x5 matrix and
calculates its values of that particular matrix and then it forms a 3x3 new matrix.Similarly
for all matrices as shown in the above figure.

19
Max Pooling also performs as a Noise Suppressant. It discards the noisy
activations altogether and also performs de-noising along with dimensionality reduction.
On the other hand, Average Pooling simply performs dimensionality reduction as a
noise suppressing mechanism. Hence Max Pooling performs a lot better than Average
Pooling. The Convolutional Layer and the Pooling Layer, together form the i-th layer of
a Convolutional Neural Network. Depending on the complexities in the images, the
number of such layers may be increased for capturing low-level details even further, but
at the cost of more computational power.

Fig 4.6 : Max & Average Pooling

Fig 4.6 explains about max & Average pooling.In max pooling it will take max number in
every matrix.In Average pooling it will take Average number in every matrix.

20
4.7 FULLY CONNECTED LAYER

Adding a Fully-Connected layer is a (usually) cheap way of learning


non-linear combinations of the high-level features as represented by the output of the
convolutional layer. The Fully-Connected layer is learning a possibly non-linear function
in that space. Now convert our input image into a suitable form for our MultiLevel
Perceptron, shall flatten the image into a column vector. The flattened output is fed to a
feed-forward neural network and backpropagation applied to every iteration of training.
Over a series of epochs, the model is able to distinguish between dominating and
certain low-level features in images and classify them using the Softmax Classification
technique.

Fig 4.7 : Fully Connected Layer Block Diagram

Fig 4.7 represents Fully Connected Layer Block Diagram.In this layer from input volume
32x32x1 converts into convolution layer stride 1 and then converts into max pooling
layer stride 2.Using flatten layer and fully connected layer with relu activation function
converts into soft-max layer.

21
4.8 CNN WORKING

An RGB image is nothing but a matrix of pixel values having three planes
whereas a grayscale image is the same but it has a single plane. Take a look at this
image to understand more. For simplicity, let’s stick with grayscale images to
understand CNNs working.

Fig 4.8 : Three Colour Channels

Fig 4.8 indicates Three Colour Channels.Three colours are red,green,blue with width 4
units pixels and height 4 units pixels with different matrices.

22
Fig 4.9 : Kernel View

Fig 4.9 shows a convolution. Take a filter/kernel(3×3 matrix) and apply it to the input
image to get the convolved feature. This convolved feature is passed on to the next
layer.

23
Fig 4.10 : Convolved Feature

Fig 4.10 indicates convolved features.From Image matrix converted into convolved
feature.It converts and takes as 5x5 matrix and calculates its values of that particular
matrix and then it forms a 3x3 new matrix.Similarly for all matrices as shown in the
above figure.

In the case of RGB colour, channels take a look at this animation to understand
its working.Convolutional neural networks are composed of multiple layers of artificial
neurons. Artificial neurons, a rough imitation of their biological counterparts, are
mathematical functions that calculate the weighted sum of multiple inputs and output an
activation value.

When given an input image in a ConvNet, each layer generates several activation
functions that are passed onto the next layer. The first layer usually extracts basic
features such as horizontal or diagonal edges. This output is passed on to the next layer
which detects more complex features such as corners or combinational edges. As it

24
moves deeper into the network it can identify even more complex features such as
objects, faces, etc….

Fig 4.11 : Kernel Channel

Fig 4.11 shows the Kernel Channel of CNN.Considering three colour channels as input
channel and converting into kernel channel as 3x3 matrix and predicting the output.

25
CHAPTER - 5

RESULTS AND DISCUSSION

5.1 CAPTURED IMAGES AND INPUT

Fig 5.1 : Captured Images

26
Fig 5.1 indicates Captured Images.Images captured using pyscreenshot package are
shown in the above figure.

Fig 5.2 : Captured Image Function Code

Fig 5.2 shows captured Image Function Code.To collect images, a pyscreenshot
package can be used. This package can be downloaded using pip which is a package
management tool that is written in python and used to install python packages. This pip
can be automatically installed during installation of Python.To install pyscreenshot,open
any terminal and type command is pip install pyscreenshot importing time because to
stop my execution for some second of time so that next image (digit) can be drawn.This
coordinate value indicates which part of your screen to be captured. Inorder to want our
drawn region to be captured,So use trial and error methods to find this coordinate. This
can also try using this same coordinate for the first run. But it might be different as our
laptop size may not be the same. So,use trial and error methods here.

27
5.2 CREATE DATA

Fig 5.3 : Create Data Code

Fig 5.3 represents Create Data Code.Creating data using numpy alias name as np
,array.If the condition satisfies then that particular block will execute if it does not
satisfies then it will exit.

28
Fig 5.4 : Create Function
Fig 5.4 indicates Create function.In this data is created and loaded.Once created,it will
shuffle the data randomly.

5.3 DIVIDING DATA INTO TRAINING AND TESTING PART

Fig 5.5 : Data Dividing Code

Fig 5.5 shows Data Dividing Code.Data divided into training and testing part.800 images
for training part and 200 images for testing part.

29
5.4 BUILDING THE MODEL

Fig 5.6 : Importing Necessary Python Libraries

Fig 5.6 indicates Importing Necessary Python Libraries.Here importing libraries such as
warnings,tensorflow,tflearn,conv_2d,max_pool_2d,input_data,dropout,fully_connected,r
egression.

30
Fig 5.7 : Executing Epoch

Fig 5.7 represents Executing Epoch.Epoch is the number of times that the learning
algorithm will work through the entire training dataset.

31
5.5 PREVIEW OF IMAGE

Fig 5.8 : Preview of Image

Fig 5.8 depicts preview of Image using idx from dataset.

32
5.6 PREDICT AND DISPLAY

Fig 5.9 : Creating Test Data

Fig 5.9 represents Creating Test Data.Using dataset 20% of data used for testing
purpose and created test data.

Fig 5.10 : Digits Classification

33
Fig 5.10 indicates Classification of Handwritten Digits.From Digits 0 to 9 it is classified
and predicted correctly as shown in the figure.

Fig 5.11 : Image Prediction Code

34
Fig 5.11 Image Prediction Code.Using cv2 and numpy images were predicted.

5.7 PREDICTION OF DIGITS

Fig 5.12 : Prediction of Digit 0

35
Fig 5.13 : Prediction of Digit 1

Fig 5.14 : Prediction of Digit 2

36
Fig 5.15 : Prediction of Digit 3

Fig 5.16 : Prediction of Digit 4

37
Fig 5.17 : Prediction of Digit 5

Fig 5.18 : Prediction of Digit 6

38
Fig 5.19 : Prediction of Digit 7

Fig 5.20 : Prediction of Digit 8

39
Fig 5.21 : Prediction of Digit 9
5.8 ACCURACY

Fig 5.22 : Accuracy

Figure 5.22 shows the 92.5 % accuracy of the Handwritten Digits Classification using
Convolutional Neural Network.

40
CHAPTER - 6

CONCLUSION & FUTURE SCOPE

In this discussion about the Convolutional Neural Network and its importance. It
also covered how a dataset is divided into training and test dataset.Here considered
80% data for training and 20% data for testing. It means that over all 1000 Images from
that took 800 for training and 200 images for testing. A dataset was taken to make
predictions of handwritten digits from 0 to 9. The dataset was cleaned, scaled, and
shaped. Using TensorFlow, a CNN model was created and was eventually trained on
the training dataset. Finally, predictions were made using the trained model with an
accuracy 92.5%.In this successfully predicted all digits from 0 to 9.

In the future, plan to observe the variation in overall classification accuracy by


varying the number of hidden layers and also toggling with other parameters of the
model.Plan to make our model more optimised in this direction also make our model
recognize the rotated 6 and 9 image(s).

Plan to achieve better accuracy results on the coloured images also as there can
be various boundary conditions that may exist in coloured images. Also try to implement
our models on letters and a double-digit(s) database so that can extend our
implementation and can diversify our model’s application.In future look forward to
working with Double Digit and Triple Digit Numbers and also will plan to predict
characters also.

41
REFERENCES

1. Arif R.B,Siddique A.B, M. M. R. Khan and Z. Ashrafi, "Study and Observation of


the Variations of Accuracies for Handwritten Digits Recognition with Various
Hidden Layers and Epochs using Neural Network Algorithm," in 2018 4th
International Conference on Electrical Engineering and Information &
Communication Technology (iCEEiCT), 2018, pp. 118-123: IEEE.

2. Adwait Dixit , Ashwini Navghane, Yogesh Dandawate,”Handwritten Devnagari


character Recognition using Wavelet Based Feature Extraction and Classification
Scheme”, 2014, Annual IEEE India Conference(INDICON).

3. Ashutosh Aggarwal ,Karamjeet Singh, kamalpreet Singh,”Use of Gradient


Technique for extracting features from Handwritten Gurmukhi Characters and
Numerals”, 2014, International Conference on Information and Communication
Technologies (ICICT 2014).

4. Akanksha Gaur, Sunita Yadav, “Handwritten Hindi character Recognition using


K-Means Clustering and SVM”, 978-1-4799- 5532-9/15/$31.00 ©2015 IEEE.

5. Archana N.Vyas, Mukesh m.Goswami, “Classification of Handwritten Gujarati


Numerals”, 978-1-4799-8792- 4/15/$31.00 ©2015 IEEE.

6. Denker J. S Gardner W. R., Graf, H. P., Henderson, D., Howard, R. E.,


Hubbard, W., Jackal, L. D., Baird, H. S., and Guyon, I. (1989). Neural Network
Recognizer for Hand-Written Digits. In Touretzky, D., editor, Neural
Information Processing Systems, volume 1, pages 323-331, Denver, 1988.

42
7. Fabien Lauer, Ching Y. Suen, and Gerard Bloch “A trainable feature extractor for
handwritten digit recognition”, Journal Pattern Recognition, Elsevier, 40 (6),
pp.1816-1824, 2007.
8. Gil Levi and Tal Hassner, "OFFLINE HANDWRITTEN DIGIT RECOGNITION
USING NEURAL NETWORK", International Journal of Advanced Research in
Electrical, Electronics and Instrumentation Engineering, vol. 2, no. 9, pp. 4373
-4377, 2013

9. Gunjan Singh et al, “Recognition of Handwritten Hindi Characters using


Backpropagation Neural Network” 2012 / (IJCSIT) International Journal of
Computer Science and Information Technologies, Vol. 3 (4) ,4892-4895

10. Gurpreet Singh, Manoj Sachan, “Multi-Layer Perceptron(MLP) neural Network


Technique for Offline Handwritten gurmukhi Character Recognition”,
978-1-4799-3975-6/14/$31.00 ©2014 IEEE

11. Haider A. Alwzwazy1, Hayder M. Albehadili2, Younes S. Alwan3, Naz E. Islam4,


"Handwritten Digit Recognition using Convolutional Neural Network",
International Journal of Innovative Research in Computer and Communication
Engineering, vol. 4, no. 2, pp. 1101-1106, 2016.

12. Ishani Patel, Viraj Jagtap and Ompriya Kale. "A Survey on Feature Extraction
Methods for Handwritten Digits Recognition", International Journal of Computer
Applications, vol. 107, no. 12, pp. 11-17, 2014.

13. Jain A.K and D. Zongker, "Representation and recognition of handwritten digits
using deformable templates," in IEEE Transactions on Pattern Analysis and
Machine Intelligence, vol. 19, no. 12, pp. 1386-1390, Dec. 1997.

14. José-Sergio Ruiz-Castilla, Juan-José RangelCortes, Farid García-Lamont,


Adrián True Espinosa. "Chapter 54 CNN and Metadata for Classification of

43
Benign and Malignant Melanomas'', Springer Science and Business Media LLC,
2019

15. Kussul E and T. Baidik, "Improved method of handwritten digit recognition tested
on MNIST database," Image and Vision Computing, vol. 22, no. 12, pp. 971-981,
2004.

16. Manoj Kumar Mahto, Karamjeet Bhatia, R.K.Sharma, “Combined Horizontal and
Vertical Projection feature Extraction Technique for Gurmukhi Handwritten
Character Recognition”, 2015, International conference on Advances in
Computer Engineering and Applications (ICACEA).

17. Neha Sahu, Nitin Kali Raman,”An Efficient handwritten Digit Recognition System
Using Artificial Neural Network”, 978-1-4673-5090-7/13/$31.00 ©2013 IEEE.

18. Neves, R. F., Alberto Filho, N. G., Mello, C. A., & Zanchettin, C. A SVM based
off-line handwritten digit recognizer. In System, IEEE International Conference on
Man, and Cybernetics (SMC) (pp. 510-515), 2011

19. Nimisha Jain, Kumar Rahul, Ipshita Khamaru. AnishKumar Jha, Anupam Ghosh
(2017). “HandWritten Digit Recognition using Convolutional Neural Network
(CNN)”, International Journal of Innovations & Advancement in Computer
Science, IJIACS,ISSN 2347 – 8616,Volume 6, Issue 5.

20. Oishe M R,Siddique M. A. B,R. B. Arif, M. M. R. Khan, "Study and Observation of


the Variations of Accuracies for Handwritten Digits Recognition with Various
Hidden Layers and Epochs using Convolutional Neural Network," in 2018 4th
International Conference on Electrical Engineering and Information &
Communication Technology (iCEEiCT), 2018, pp. 112-117: IEEE.

44
21. Plamondon, R., & Srihari, S. N. Handwritten digits recognition IEEE Transactions
on Pattern Analysis and Machine Intelligence, 22(1), 63-84

22. Saeed AL-Mansoori, "Intelligent Handwritten Digit Recognition using MLP and
Artificial Neural Network", Int. Journal of Engineering Research and Applications,
vol. 5, no. 5, pp. 46-51, 2015.

23. Vinjit B.M, M. K. Bhojak, S. Kumar and G. Chalak, "A Review on Handwritten
Character Recognition Methods and Techniques," 2020 International Conference
on Communication and Signal Processing (ICCSP), Chennai, India, 2020, pp.
1224-1228, DOI: 10.1109/ICCSP48568.2020.9182129.

24. Viragkumar N. Jagtap, Shailendra K. Mishra, "Fast Efficient Artificial Neural


Network for Handwritten Digit Recognition", International Journal of
ComputerScience and Information Technologies, vol. 52, no. 0975-9646, pp.
2302-2306, 2014.

25. Xiao-Xiao Niu n , Ching Y. Suen “A novel hybrid CNN–SVM classifier for
recognizing handwritten digits” Pattern Recognition 45 (2012) 1318–1325, 2011

26. Youssouf Chherawala, Partha Pratim Roy and Mohamed Cheriet, “Feature Set
Evaluation for Offline Handwriting Recognition Systems: Application to the
Recurrent Neural Network,” IEEE TRANSACTIONS ON CYBERNETICS, VOL.
46, NO. 12, DECEMBER 2016.

45

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy