Question

I am a beginner in using the ImageDataGenerator from Keras and I accidentally used model.fit instead of model.fit_generator.

def gen_Image_data():
   gen = ImageDataGenerator(
           width_shift_range=0.1,
           horizontal_flip=True)
   return gen




train_gen = gen_Image_data()
test_gen = ImageDataGenerator()

train_samples = train_gen.flow(X,y, batch_size=64)
test_samples = test_gen.flow(X_val, y_val, batch_size=64)

history = model.fit(train_samples, steps_per_epoch = np.ceil(len(X)/64),
              validation_data=(test_samples),
              validation_steps=np.ceil(len(X_val)/64),
              epochs=300, verbose=1, callbacks=[es])

Many thanks for every hint

Was it helpful?

Solution

The data augmentations are defined when you instantiate your data generators. An example is as such:

train_datagen = ImageDataGenerator(
        rescale=1./255,
        shear_range=0.2,
        zoom_range=0.2,
        horizontal_flip=True)

Other augmentation techniques can also be used by setting the correct parameters. Refer to this link: https://keras.io/preprocessing/image/

Licensed under: CC-BY-SA with attribution
Not affiliated with datascience.stackexchange
scroll top