3
$\begingroup$

I am working on a deep learning project for face recognition. I am using the pre-trained model VGG16.

The dataset has around 100 classes, and each class have 80 images. I split the dataset 60% training, 20% validation, 20% testing. I used data augmentation (ImageDataGenerator()) to increase the training data.

The model gave me different results when I change ImageDataGenerator() arguments. See the following cases:

Case1:

 train_datagen = ImageDataGenerator(
    rotation_range=15,
    width_shift_range=0.2,
    height_shift_range=0.2,
    shear_range=0.2,
    zoom_range=0.2,
    horizontal_flip=True,
    fill_mode='nearest')
validate_datagen = ImageDataGenerator()
Test_datagen = ImageDataGenerator()

Case1 result: High training accuracy and validation accuracy, but the training accuracy is lower. check the following image:

Case1 accuracy Case1 loss

Case2:

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

validate_datagen = ImageDataGenerator()
    Test_datagen = ImageDataGenerator()

Case2 result: Overfitting. check the following image: Case2 accuracy Case2 loss

Case3:

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

validate_datagen = ImageDataGenerator(rescale=1./255)
    Test_datagen = ImageDataGenerator(rescale=1./255)

Case3 result: High training accuracy and validation accuracy, but the training accuracy is lower.. check the following image: case3 accuracy case3 loss

1- Why does using augmentation in validation and testing data ImageDataGenerator(rescale=1./255) in case3 give different result than case2?

2- Is adding ImageDataGenerator(rescale=1./255) to the testing and validation better than not adding it?

3- Do you think there is a problem in the result of the first case?

$\endgroup$

1 Answer 1

2
$\begingroup$
  • 1 and 2: If you rescale you images, you should do it on all partitions: training, validation and test. If you only rescale your images on the training set, then your network will see very different values (0~255, vs 0.0~1.0) on validation/test set and therefore give poor accuracy. That's your case 2.

  • I don't see any obvious problem.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.