training convnet from scratch on small dataset would be exposed to every possible aspect of the data distribution at handyou would never overfit data augmentation takes the approach of generating more training data from existing training samplesby augmenting the samples via number of random transformations that yield believable-looking images the goal is that at training timeyour model will never see the exact same picture twice this helps expose the model to more aspects of the data and generalize better in kerasthis can be done by configuring number of random transformations to be performed on the images read by the imagedatagenerator instance let' get started with an example listing setting up data augmentation configuration via imagedatagenerator datagen imagedatageneratorrotation_range= width_shift_range= height_shift_range= shear_range= zoom_range= horizontal_flip=truefill_mode='nearest'these are just few of the options available (for moresee the keras documentationlet' quickly go over this coderotation_range is value in degrees ( - ) range within which to randomly rotate pictures width_shift and height_shift are ranges (as fraction of total width or heightwithin which to randomly translate pictures vertically or horizontally shear_range is for randomly applying shearing transformations zoom_range is for randomly zooming inside pictures horizontal_flip is for randomly flipping half the images horizontally--relevant when there are no assumptions of horizontal asymmetry (for examplereal-world picturesfill_mode is the strategy used for filling in newly created pixelswhich can appear after rotation or width/height shift let' look at the augmented images (see figure listing displaying some randomly augment ed raining images from keras preprocessing import image fnames [os path join(train_cats_dirfnamefor fname in os listdir(train_cats_dir)img_path fnames[ module with imagepreprocessing utilities chooses one image to augment img image load_img(img_pathtarget_size=( )licensed to reads the image and resizes it