Data preparation

We will keep the data size smaller by using only the first 2,000 images in the training and test data from CIFAR10. This will allow the image classification model to be run on a regular computer or laptop. We will also resize the training and test images from 32 x 32 dimensions to 224 x 224 dimensions to be able to compare classification performance with the pretrained model. The following code includes the necessary preprocessing that we went over earlier in this chapter:

# Selecting first 2000 imagestrainx <- data$train$x[1:2000,,,] testx <- data$test$x[1:2000,,,] # One-hot encodingtrainy <- to_categorical(data$train$y[1:2000,], num_classes = 10)testy <- to_categorical(data$test$y[1:2000,] , num_classes = 10)# Resizing ...

Get Advanced Deep Learning with R now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.