Skip to main content

Tackling MNIST Dataset : Deep Convolutional Neural Network 99.571% accurate

Hey there! My dear readers. 

Today this kernel review is going to be about the famous MNIST data-set, one of the most famous introductory datasets which we encounter along side Iris dataset and the titanic survival challenge data sets. 

Since it is a competition kernel, I have decided not to make it public. (yet)


Also,  if you want to try your hands at the challenge itself, then you can find the challenge page here : 





Note: This kernel has been largely focused on network modelling rather than Exploratory Data Analysis because it's simple, classic stuff. Still, I will try my best to explain that stuff here.


Exploratory Data Analysis


First indication of a great dataset is the face that it gives all the mentioned labels equal rows in it and this one doesn't disappoint.

This data set maintains a fair 4000+ entries per label which actually is a great statistic for a good dataset.



And the next thing one needs to know is how does that data look like?
For that, matplotlib's module comes handy. Essentially, in the dataset, each row describes pixel density in 1s and 0s,  which can be represented like this : 



Feature Engineering

Using the following processes, the dataset is perfectly pre processed. Mainly it converts the label data types into int32 and reshapes the training and testing numpy arrays into (number_of_examples, x_dimension, y_dimension, 1) . You must be thinking why 1? Well, we are dealing with black and white images. So 1 channel is sufficient, in case of colored images, you may want to use 3 channels.

To follow my steps, you can have fun using this code snippet:


Model Design

Here comes the fun part. I have modeled my own CNN in this way. Implementing Batch normalization, Dropouts and combined the classical CNN and Rectilinear Units in the end to try and maximize the accuracy. You can use this model here:  





I would like to extend the inspiration for the Tier 1 to Yug Khanna's model.
The model comes out to have the following architecture:

Model Training

The model architecture is fairly complex in itself, but there is one more technique i have used to complement the architectures training process. Namely Data Augmentation , using ImageDataGenerator, we achieve the same. The following code can be used to achieve the same.



The accuracy curve

Result

The resulting prediction hits the lovely accuracy score of 0.99571 which fetches you a rank in top 14% of the leader board! Hope you enjoyed this kernel!
I will soon release the kernel in public. Till then, enjoy your day!

Uddeshya Singh 

Comments

Total Pageviews

Popular posts from this blog

Kaggle Dataset Analysis : Is your Avocado organic or not?

Hey readers! Today, allow me to present you yet another dataset analysis of a rather gluttony topic, namely Avocado price analysis. This Data set  represents the historical data on avocado prices and sales volume in multiple US markets. Our prime objectives will be to visualize the dataset, pre-process it and ultimately test multiple sklearn classifiers to checkout which one gives us the best confidence and accuracy for our Avocado's Organic assurance! Note : I'd like to extend the kernel contribution to Shivam Negi . All this code belongs to him. Data Visualization This script must procure the following jointplot  While a similar joint plot can be drawn for conluding the linearly exponent relations between extra large bags and the small ones. Pre Processing The following script has been used for pre processing the input data. Model Definition and Comparisons We will be looking mostly at three different models, namely ra...

IOT Breakthrough : TensorFlow 1.9 Officially Supports the Raspberry Pi

Hey Readers! Good news for all the "cheap fair power" computer fans, as a result of a major collaboration effort between TensorFlow and Raspberry Pi foundation, one can now install tensorflow precompiled binaries using Python's pip package system !  When TensorFlow was first launched in 2015, they wanted it to be an “ open source machine learning framework for everyone ”. To do that, they needed to run on as many of the platforms that people are using as possible. They have long supported Linux, MacOS, Windows, iOS, and Android, but despite the heroic efforts of many contributors, running TensorFlow on a Raspberry Pi has involved a lot of work. If one is using Rasbian9 they can simply use these 2 commands to install tensorflow on their machine! According to an excerpt from TensorFlow's medium article page :  " We’re excited about this because the Raspberry Pi is used by many innovative developers, and is also widely used in education to ...

5 AI advices you need to implement, from TODAY: DeepMind CoFounder

Data Science and Artificial Intelligence fans, this might be a good day for you. Google DeepMind Cofounder gives a teenage AI fan  pieces of advice, and I think you should know that too! Some artificial intelligence specialists at organizations like Google and Facebook are currently acquiring more cash than venture financiers at Goldman Sachs and J.P. Morgan.  These specialists additionally have the benefit of working in a field of technology that is ready to majorly affect the world we live in.  Be that as it may, for some individuals, it's not clear how to approach landing a job in AI. This week, 17-year-old Londoner Aron Chase asked Shane Legg — the chief scientist and cofounder of DeepMind, an AI lab acquired by DeepMind for a reported £400 million — for five pieces of advice for an AI enthusiast like himself. " Hey Shane I’m currently 17 from London England and am very passionate about AI, also learning about in-depth human needs. What would be the 5 piec...