16.03.2021 Views

Advanced Deep Learning with Keras

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Introducing Advanced Deep Learning with Keras

The significance of MaxPooling2D is the reduction in feature maps size which

translates to increased kernel coverage. For example, after MaxPooling2D(2),

the 2 × 2 kernel is now approximately convolving with a 4 × 4 patch. The CNN

has learned a new set of feature maps for a different coverage.

There are other means of pooling and compression. For example, to achieve

a 50% size reduction as MaxPooling2D(2), AveragePooling2D(2) takes the

average of a patch instead of finding the maximum. Strided convolution,

Conv2D(strides=2,…) will skip every two pixels during convolution and

will still have the same 50% size reduction effect. There are subtle differences

in the effectiveness of each reduction technique.

In Conv2D and MaxPooling2D, both pool_size and kernel can be non-square. In

these cases, both the row and column sizes must be indicated. For example, pool_

size=(1, 2) and kernel=(3, 5).

The output of the last MaxPooling2D is a stack of feature maps. The role of Flatten

is to convert the stack of feature maps into a vector format that is suitable for either

Dropout or Dense layers, similar to the MLP model output layer.

Performance evaluation and model summary

As shown in Listing 1.4.2, the CNN model in Listing 1.4.1 requires a smaller number

of parameters at 80,226 compared to 269,322 when MLP layers are used. The

conv2d_1 layer has 640 parameters because each kernel has 3 × 3 = 9 parameters,

and each of the 64 feature maps has one kernel and one bias parameter. The number

of parameters for other convolution layers can be computed in a similar way. Figure

1.4.5 shows the graphical representation of the CNN MNIST digit classifier.

Table 1.4.1 shows that the maximum test accuracy of 99.4% which can be achieved

for a 3–layer network with 64 feature maps per layer using the Adam optimizer with

dropout=0.2. CNNs are more parameter efficient and have a higher accuracy than

MLPs. Likewise, CNNs are also suitable for learning representations from sequential

data, images, and videos.

[ 28 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!