In this section, will use the Keras library, which also includes MNIST data. We will also make use of the EBImage library, which is useful for processing image data. MNIST data contains handwritten images from 0 to 9. Let's take a look at the following code to understand this data:
# Libraries and MNIST data
library(keras)
library(EBImage)
mnist <- dataset_mnist()
str(mnist)
List of 2
$ train:List of 2
..$ x: int [1:60000, 1:28, 1:28] 0 0 0 0 0 0 0 0 0 0 ...
..$ y: int [1:60000(1d)] 5 0 4 1 9 2 1 3 1 4 ...
$ test :List of 2
..$ x: int [1:10000, 1:28, 1:28] 0 0 0 0 0 0 0 0 0 0 ...
..$ y: int [1:10000(1d)] 7 2 1 0 4 1 4 9 5 9 ...
From the preceding code, we can make the following observations:
- Looking at the structure of this data, we can see that there are 60,000 images in the training data and 10,000 images in the test data.
- These handwritten images...