logistic regression to recognizance handwritten numbers
Overview
This is a quick example on how to a neuron performs classifying hand reading digits
You can download or run this code from here
Download data
The first thing you want to do is to download your data.MIST comes pre-loaded with TensorFlow,
you can download it suing the following command
Visualize data
Finding out the size of your data, how it looks, and image dimensions can help you know what type of ML
algorithms to use and what type of postprocessing is needed.
Tensorflow basics:
A placeholder is a variable that we can use to transfer a value when we run our Tensorflow session.
It creates a memory space for variables that will be using in the future.
In this case x stands for our images and y for our labels
Logits is a matrix with an estimate number of how likely the input image is to be
of the a class. In order for this number to look like a provability we have to normalize
them (zero to one) using softmax.
Architecture
Training Graph
Validation Graph
Start tensorflow training session
Start tensorflow training session
Output:
Total time 0.46s accuracy:0.9104
Total time 0.45s accuracy:0.9158
Total time 0.44s accuracy:0.9184
Total time 0.45s accuracy:0.9204
Total time 0.50s accuracy:0.9226
Total time 0.51s accuracy:0.924
Total time 0.51s accuracy:0.9248
Total time 0.50s accuracy:0.9264
Total time 0.51s accuracy:0.926
Total time 0.54s accuracy:0.926
Total time 0.49s accuracy:0.9264
Total time 0.50s accuracy:0.9274
Total time 0.49s accuracy:0.9278
Total time 0.49s accuracy:0.929
Total time 0.51s accuracy:0.9294
-1.6156687
1.2737342
Conclusion
With out suing any sophisticated architectures, a single neuron net was able to get 93% accuracy at MINST dataset.