Predicting handwritten digits
Our final application for neural networks will be the handwritten digit prediction task. In this task, the goal is to build a model that will be presented with an image of a numerical digit (0–9) and the model must predict which digit is being shown. We will use the MNIST database of handwritten digits from http://yann.lecun.com/exdb/mnist/.
From this page, we have downloaded and unzipped the two training files, train-images-idx3-ubyte.gz
and train-images-idx3-ubyte.gz
. The former contains the data from the images and the latter contains the corresponding digit labels. The advantage of using this website is that the data has already been preprocessed by centering each digit in the image and scaling the digits to a uniform size. To load the data, we've used information from the website about the IDX format to write two functions:
read_idx_image_data <- function(image_file_path) { con <- file(image_file_path, "rb") magic_number <- readBin(con, what...