Digit five from the training data

Although a generative adversarial network can be developed to generate all 10 digits, for someone just getting started, it is advisable to get started with just one digit. Let's take a look at the following code:

# Data on digit five
c(c(trainx, trainy), c(testx, testy)) %<-% mnist
trainx <- trainx[trainy==5,,]
str(trainx)
int [1:5421, 1:28, 1:28] 0 0 0 0 0 0 0 0 0 0 ...
summary(trainx)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.00 0.00 0.00 33.32 0.00 255.00

par(mfrow = c(8,8), mar = rep(0, 4))
for (i in 1:64) plot(as.raster(trainx[i,,], max = 255))
par(mfrow = c(1,1))

As seen in the preceding code, we are selecting images that contain digit five and are saving them in trainx. The structure of trainx shows us that there are 5,421 such images and they all have dimensions of 28 x 28. The summary function shows that the values in trainx range from 0 to 255. The first 64 images of the handwritten digit five from the train data can be seen in the following image:

These handwritten images show a high amount of variability. Such variability is expected since different people have different handwriting styles. Although most of these digits are clearly written and easy to recognize, there are some that are somewhat less clear.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset