Enhancing the model with additional layers

In this section, we add two important layers: the convolution layer, and pooling layer:

  1. Before beginning, we make one small change to the data structure. We will add a fourth dimension that is a constant value. We add the extra dimension using the following code:
dim(train) <- c(nrow(train), 28, 28, 1) dim(test) <- c(nrow(test), 28, 28, 1) 

When we make this change, we can see the added dimension for these data objects in the Environment pane, which will look like the following image:

We make this change to the structure because it is a requirement of modeling a CNN using keras.

  1. As before, the ...

Get Hands-On 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.