April 2017
Intermediate to advanced
318 pages
7h 40m
English
Another way to improve the performance is to generate more images for our training. The key intuition is that we can take the standard CIFAR training set and augment this set with multiple types of transformations including rotation, rescaling, horizontal/vertical flip, zooming, channel shift, and many more. Let us see the code:
from keras.preprocessing.image import ImageDataGeneratorfrom keras.datasets import cifar10import numpy as npNUM_TO_AUGMENT=5#load dataset(X_train, y_train), (X_test, y_test) = cifar10.load_data()# augumentingprint("Augmenting training set images...")datagen = ImageDataGenerator(rotation_range=40,width_shift_range=0.2,height_shift_range=0.2,zoom_range=0.2, ...