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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.