Data preparation

Next, we will reshape images in the required format using the following code:

# Reshape
trainx <- array_reshape(trainx, c(nrow(trainx),28,28,1)) testx <- array_reshape(testx, c(nrow(testx),28,28,1)) trainx <- trainx / 255 testx <- testx / 255

Here, we've reshaped the training data so that it's 60,000 x 28 x 28 x 1 in size and reshaped the test data so that it's 10,000 x 28 x 28 x 1 in size. We also divided the pixel values that are between 0 and 255 by 255 to obtain a new range that is between 0 and 1.

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

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