Mary PW Chin
钱碧慧博士 PhD (Wales), MSc (Surrey) E-mail:
Slides here are continuously being revised and updated. If you have been here before, your browser might have some old files cached. To ensure that you see the latest version, please follow the instructions given in the following link:
☞ how to clear browser cache.
For every program you encounter it is always an excellent exercise to change the variable names to names which are most meaningful to you, then make the program run. You will gain deeper understanding of the program. You will see the program in a new light. Everyone is different: variable names most intuitive to me differ from variable names most intuitive to you. My programs are written with variable names most intuitive to me, so you should change them to names most intuitive to you so that the program flow becomes more obvious.
Collect some samples of handwritten digits, digitise either by scanning with a scanner or just take a photo. If you choose to take a photo, try your best to keep the aspect ratio correct -- avoid photo-taking from an angle. Down-sample the images to 8 by 8 pixels using a graphics software. Without down-sampling, there would be no hope of getting this exercise to work. Transfer the image files to your file space (PythonAnywhere is you are using PythonAnywhere, or wherever you run Python). Use
matplotlib.pyplot.imread to read the files. Modify the program given in the slides, run and see whether the program can recognise the digits in your samples.
You may also try typing out digits on your favourite word-processor, use the full collection of fonts available. Save as image files. Remember to downsample to 8 by 8 pixels per digit. Try using your newly collected samples as training dataset or testing dataset.