1
$\begingroup$

I am working on image classification using CNNs and the pretrained model VGG16, my dataset has 3 classes with almost 900 images per class. after traning for 5 epochs my model reached 1 accuracy with 0.00073 train-loss , val-loss=0.00000, val-accuracy=1. Is it normal to reach 100% accuracy ? I have to add that my images per class are very similar so this makes the learning easier. The evaluation on my test set is: 100% accuracy, loss = 0.0000. Here is my traning and learning curves. Training learning curves

$\endgroup$
3
  • $\begingroup$ Did you train just the last layer or more? $\endgroup$
    – serali
    Sep 24, 2021 at 13:10
  • $\begingroup$ I freezed the layers of the vgg16 and added a fully connected layer.please, what do you want to say exactly from this "You might want to keep a separate "Test Data", because I have some pictures that I left to see the results of the prediction, so what do you want me to do with them exactly? thanks. @serali $\endgroup$
    – Lema Zaidi
    Sep 24, 2021 at 13:14
  • $\begingroup$ For completeness, this probably needs to be in the comments of the answer below so I am editing my answer. $\endgroup$
    – serali
    Sep 24, 2021 at 13:18

3 Answers 3

1
$\begingroup$

Given that you are using transfer learning from a very large model, and the images you have in each class is very similar with each other, and very distinct from images in other classes, I guess it is possible to get %100 accuracy.

I don't see any problems in your screenshots. Validation is run at the end of each epoch so it is expected to get better results from training, especially in the first run. You might want to keep a separate "Test Data" which you never use in training and validation - I mean which the model never sees, and use it at the very end to confirm your result.

Use the images you kept to simply make predictions with you final model. Check this article for a description of training, validation and test sets. Or this reference on TensorFlow Documentation which describes evaluation process in detail.

$\endgroup$
0
$\begingroup$

100% accuracy with a 0.000 loss function is usually a bag sign in image classification. This usually means that your model is overfitting.

Overfitting is the production of an analysis that corresponds too closely or exactly to a particular set of data, and may therefore fail to fit additional data or predict future observations reliably,

You've also that the images are very similar to each other which also proves that the results produced are because of overfitting.

Refer to "How to Avoid Overfitting in Deep Learning Neural Networks" to fix this issue.

$\endgroup$
1
  • $\begingroup$ but you can see from the learning curves that there is no overfitting and also, in case of overfitting, the validation loss will be increasing but in my case it's not. @tonyJesuthasan $\endgroup$
    – Lema Zaidi
    Sep 24, 2021 at 13:15
0
$\begingroup$

Sounds like it could be a normalization problem if you're getting such high accuracy. Have a look at the file types in your image classes. If one class is exclusively png and another jpg it could be the compression that the model differentiates on.

I have had a project where JPEG quality ended up causing a model to achieve 100% accuracy but that could be fixed with PIL.

Without seeing your data I can't say what issue you may have but I would go back and look at my data closely if I were you. Also try your model on a test set too.

If you're sure your data is fine and your model still achieves such high accuracy on your test set then nothing to worry about.

$\endgroup$
1
  • $\begingroup$ thanks for answering @djeoff. All my files (images) types are JPG, what should I do in this case please ? $\endgroup$
    – Lema Zaidi
    Sep 26, 2021 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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