Hand-written Digit Recognition

조회 수: 13 (최근 30일)
Hani Haidar
Hani Haidar 2019년 12월 20일
편집: Image Analyst 2019년 12월 20일
Hello, I am trying to implement a simple handwritten digit recognizer using knn. For this purpose, I am using the famous MNIST dataset to train the model and a handwrittern digit image using paint program.
To explain briefly, MNIST is a dataset that contains 60000 training samples of different handwritten digits and 10000 testing samples. All these digits are centered in 28x28 pixel images with black background and white font color, then they are reshaped to form a 1x784 row and that is what each row of the dataset contains.There is also a label column for these digits.
What I did so far is reading an image in matlab, transforming it to mnist format then training the model using the training samples and testing it using the image I transformed but I got the same prediction whatever the digit is, then I found something about elastic deformations and I tried it but still false predictions with slight change in the predictions.
The MNIST dataset I am using can be found under this link: https://github.com/daniel-e/mnist_octave/raw/master/mnist.mat
I attached the matlab file I wrote and a sample of the image and how it looks after transformation to mnist format and I am looking forward to your help.
Thank you in advance
  댓글 수: 2
Ridwan Alam
Ridwan Alam 2019년 12월 20일
편집: Ridwan Alam 2019년 12월 20일
if you don't mind, can you please explain
  1. why are you reshaping the image?
  2. what features are you extracting from the image?
  3. what are you expecting knn to learn? I am not asking about the labels; are you expecting knn to learn the cluster patterns of black and white pixels and use that to classify the images? If you used features that might've been easier for knn to learn.
  4. In your code, you're trying to predict "new". How does the model perform on testing data? you mentioned you have 10000 testing images, right?
Hani Haidar
Hani Haidar 2019년 12월 20일
편집: Image Analyst 2019년 12월 20일
Let me answer each question separately:
  1. Each row of the MNIST dataset is feature vector of a digit image of 28x28 pixels reshaped to a row of size 1x784 pixels and I am reshaping the image to match this.
  2. Each row contains each pixel intensity and I think I should extract this.
  3. I am expecting the model to learn the change in pixel intensity which are black and white for the different ways of writing the digit.
  4. I tested the model on the testing part of the dataset and got a high accuracy now I have to test the model on an image from outside the dataset and that is what I am doing.
Thank you

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by