# Model does not learn when using Keras 'flow_from_directory', but learns fine with 'image_dataset_from_directory'?

When classifying images with Keras, I am able to achieve a validation accuracy around 90-95%, however, I am trying to improve with the use of augmentation so have switched from image_dataset_from_directory, to flow_from_directory, to make use of the ImageDataGenerator.

For some reason the validation accuracy holds at 33% and does not improve? I have modified the augmentation parameters to see if that is affecting the training, but it does not seem to be that.

Could anyone explain if I am doing something wrong, or if there is an alternative method to implementing augmentation?

original: (Found 240 files belonging to 3 classes. Using 192 files for training. Found 240 files belonging to 3 classes. Using 48 files for validation. Found 60 files belonging to 3 classes.)

train_data = tf.keras.preprocessing.image_dataset_from_directory(train_dir,
image_size=img_size,
batch_size=batch_no,
seed=seed_no,
shuffle=True,
subset="training",
validation_split=0.2,
label_mode="categorical")

validation_data = tf.keras.preprocessing.image_dataset_from_directory(train_dir,
image_size=img_size,
batch_size=batch_no,
seed=seed_no,
shuffle=False,
validation_split=0.2,
subset="validation",
label_mode="categorical")

test_data = tf.keras.preprocessing.image_dataset_from_directory(test_dir,
image_size=img_size,
batch_size=batch_no,
shuffle=False,
seed=seed_no,
label_mode="categorical")


Replaced: (Found 192 images belonging to 3 classes. Found 48 images belonging to 3 classes. Found 60 images belonging to 3 classes. )

dgen_test = ImageDataGenerator(rescale = 1./255.)
dgen_train = ImageDataGenerator(rescale = 1./255.,
zoom_range = 0.2,
horizontal_flip = True,
vertical_flip= True,
rotation_range=20,
shear_range=0.2,
validation_split=0.2
)

train_data = dgen_train.flow_from_directory(train_dir,
subset='training',
target_size=img_size,
batch_size=batch_no,
shuffle=True,
seed=seed_no,
class_mode="categorical")

validation_data = dgen_train.flow_from_directory(train_dir,
subset='validation',
target_size=img_size,
batch_size=batch_no,
shuffle=False,
seed=seed_no,
class_mode='categorical')

test_data = dgen_test.flow_from_directory(test_dir,
target_size=img_size,
batch_size=batch_no,
shuffle=False,
seed=seed_no,
class_mode='categorical')
$$$$
`
• Avoid shear range and zoom range. Flips and rotations are ok. Nov 11 at 4:56