In this section, we add two important layers: the convolution layer, and pooling layer:
- 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.
- As before, the first step in the modeling process is to establish that we will be building a sequential model by calling the keras_model_sequential() function with no arguments using the following code:
set.seed(0)
model <- keras_model_sequential...