title: Validation accuracy not changing while loss is decreasing in keras image classification?
body: <p><strong>Image classification Problem</strong></p>
  <p>I have two classes of images.</p>
  <ul>
  <li>Fake</li>
  <li>Real</li>
  </ul>
  <p>Dataset splitting detail is below.</p>
  <ul>
  <li><p>Total Training FAKE Images 3457</p>
  </li>
  <li><p>Total Training REAL Images 675</p>
  </li>
  <li><p>Total validation FAKE Images 642</p>
  </li>
  <li><p>Total validation REAL Images 336</p>
  </li>
  </ul>
  <p>I have applied CNN on that but my validation accuracy is decreasing while loss is increasing. I have also applied Data Augmentation and preprocessing on data.</p>
  <pre><code>train_dir = '/content/drive/MyDrive/Training/Training Data'
  validations_dir = '/content/drive/MyDrive/Training/Validation Data'
  train_fake_dir = '/content/drive/MyDrive/Training/Training Data/FAKE'
  train_real_dir = '/content/drive/MyDrive/Training/Training Data/REAL'
  
  validation_fake_dir = '/content/drive/MyDrive/Training/Validation Data/FAKE'
  validation_real_dir = '/content/drive/MyDrive/Training/Validation Data/REAL'
  num_fake_train = len(os.listdir(train_fake_dir))
  num_real_train = len(os.listdir(train_real_dir))
  
  num_fake_validation = len(os.listdir(validation_fake_dir))
  num_real_validation = len(os.listdir(validation_real_dir))
  print(&quot;Total Training FAKE Images&quot;,num_fake_train)
  print(&quot;Total Training REAL Images&quot;,num_real_train)
  print(&quot;--&quot;)
  print(&quot;Total validation FAKE Images&quot;,num_fake_validation)
  print(&quot;Total validation REAL Images&quot;,num_real_validation)
  total_train = num_fake_train+num_real_train
  total_validation = num_fake_validation+num_real_validation
  print(&quot;Total Training Images&quot;,total_train)
  print(&quot;--&quot;)
  print(&quot;Total Validation Images&quot;,total_validation)
  
  image_gen_train = ImageDataGenerator(rescale = 1./255,rotation_range = 40,width_shift_range=0.3,
                                       height_shift_range=0.3,shear_range = 0.3,zoom_range = 0.2,
                                       horizontal_flip = True,fill_mode = 'nearest')
  train_data_gen = image_gen_train.flow_from_directory(batch_size = batch_size,
                                                       directory = train_dir,
                                                       shuffle= True,
                                                       target_size = (img_height,img_width),
                                                       class_mode = 'binary')
  image_generator_validation = ImageDataGenerator(rescale=1./255)
  val_data_gen = image_generator_validation.flow_from_directory(batch_size=batch_size,
                                                   directory=validations_dir,
                                                   target_size=(img_height,img_width),
                                                   shuffle= True,
                                                   class_mode='binary')
  classifier = tf.keras.Sequential([
          tf.keras.layers.Conv2D(16,(3,3),activation='relu',input_shape=(img_width,img_height, 3)),
          tf.keras.layers.Dropout(0.5),
          tf.keras.layers.BatchNormalization(),
          tf.keras.layers.MaxPooling2D(2,2),
          tf.keras.layers.Flatten(),
          tf.keras.layers.Dense(128,activation= 'relu'),
          tf.keras.layers.Dense(2,activation='softmax')  
  ])
  classifier.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['acc'])
  history_classifier = classifier.fit(train_data_gen,epochs = epochs,validation_data=val_data_gen,verbose = 1)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/p4dVz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p4dVz.png" alt="enter image description here" /></a></p>