1
$\begingroup$

Why in binary classification of images with CNN the loss and accuracy graph are so unstable? I mean accuracy of validation test does not increase smoothly, it goes to 80%, then comes to 60%, then again goes to 84% and so on. Same is the case with train accuracy. Now how do I know that how many epochs is the optimal number?

$\endgroup$
2
  • $\begingroup$ Adjust your batch_size and learning_rate, then see $\endgroup$
    – 10xAI
    Commented Nov 3, 2020 at 6:45
  • $\begingroup$ supprisely by decreasing the batch size sharply (from 100 to 12) it is working great. what do you think? $\endgroup$
    – Nagh
    Commented Nov 3, 2020 at 7:23

1 Answer 1

0
$\begingroup$

There is no way to definitely note how many epochs is required. Your accuracy graphs may be unstable for several reasons such as -

  1. Irregular data distribution
  2. Faulty model
  3. Large batch size (as mentioned in the comments)
  4. Overfitting and underfitting (in this case im not too sure which one)

You can fix it through the following methods -

  1. Analyse your data well and see if one class is heavily grater than other.
  2. Make sure all duplicate images are removed.
  3. Try different models, start with pre-trained. Shouldn't take much compute power.
  4. Approach transfer learning (neural networks)
  5. Adjust learning rate (as mentioned above)
  6. General hyperparameter tuning.

if the dataset is from somewhere public, see the models and the approaches others have used. You might see where your model actually lacks.

$\endgroup$

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