09.05.2023 Views

pdfcoffee

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Convolutional Neural Networks

So, we have an improvement of 15.14% with respect to the previous simpler deeper

network. For sake of completeness, let's also report the accuracy and loss during

training.

Improving the CIFAR-10 performance with

data augmentation

Another way to improve the performance is to generate more images for our

training. The idea here is that we can take the standard CIFAR training set and

augment this set with multiple types of transformation, including rotation, rescaling,

horizontal or vertical flip, zooming, channel shift, and many more. Let's see the code

applied on the same network defined in the previous section:

from tensorflow.keras.preprocessing.image import ImageDataGenerator

#image augmentation

datagen = ImageDataGenerator(

rotation_range=30,

width_shift_range=0.2,

height_shift_range=0.2,

horizontal_flip=True,

)

datagen.fit(x_train)

rotation_range is a value in degrees (0-180) for randomly rotating pictures; width_

shift and height_shift are ranges for randomly translating pictures vertically or

horizontally; zoom_range is for randomly zooming pictures; horizontal_flip is

for randomly flipping half of the images horizontally; and fill_mode is the strategy

used for filling in new pixels that can appear after a rotation or a shift.

After augmentation we have generated many more training images starting from the

standard CIFAR-10 set, as shown in Figure 15:

[ 128 ]

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

Saved successfully!

Ooh no, something went wrong!