Artificial Neural Network based Classification

Summary

  • Model developed to accurately classify data in the form of images into proper classes.
  • To employ the usage of Artificial neural network based model for prediction
  • Deploying TensorFlow’s Keras dense Network
  • Achieved an accuracy of 99.26%

Dataset

Data frame consists of handwritten images in the form of arrays of digits corresponding to the RGB color scheme. Each magnitude of the integer indicates the intensity of the brightness to form the image of digit.

These data points are in turn used to train the machine learning model to classify.

Image of handwritten number ('5')

Model development

Neural Network

A neural network is a series of algorithms that endeavors to recognize underlying relationships in a set of data through a process that mimics the way the human brain operates. In this sense, neural networks refer to systems of neurons, either organic or artificial in nature.

Neural networks can adapt to changing input; so the network generates the best possible result without needing to redesign the output criteria.

A simple neural network

A neural network has many layers. Each layer performs a specific function, and the complex the network is, the more the layers are. That’s why a neural network is also called a multi-layer perceptron.

The purest form of a neural network has three layers:

  • The input layer
  • The hidden layer
  • The output layer

As the names suggest, each of these layers has a specific purpose. These layers are made up of nodes. There can be multiple hidden layers in a neural network according to the requirements. The input layer picks up the input signals and transfers them to the next layer. It gathers the data from the outside world.

The hidden layer performs all the back-end tasks of calculation. A network can even have zero hidden layers. However, a neural network has at least one hidden layer. The output layer transmits the final result of the hidden layer’s calculation.

In Keras neural network model few parameters are to be checked:

  • Input shape - It is required to have a single array instead of 2D or 3D
  • Hidden layer - If specified (recommended) requires a network of neurons to work with algorithms such as Forward pass or back propagation
  • Activation Function - Can be used from Linear/ Relu/ Tanh/ Sigmoid
  • Ouput layer - Containing the classes

Generally it is advisable to use hidden layers as many as possible to increase the interactions between neurons and hence reduce the error.

Gradient Descent or Optimizer

The gradient is a numeric calculation allowing us to know how to adjust the parameters of a network in such a way that its output deviation is minimized.

Types of Gradient Descent

  • Batch gradient descent - Weights and bias is calculated and adjusted after every epoch
  • Stochastic gradient descent - Weights and bias is calculated and adjusted after every training sample instead of epoch
  • (Stochastic) Mini-batch gradient descent - Instead of every sample, a group of samples are executed and weights/bias is calculated accordingly

In large datasets such as this, its inefficient to use batch gradient descent hence stochastic gradient descent is preferred.

Model performance

Model performance

Deployed neural network model and reached an accuracy of 99.26%

Evaluation and conclusion

Model showed an improvement an accuracy corresponding to higher number of neurons and hidden layers.

Truth vs Predicted

Link to GitHub repository