Is my model overfitting or did I do something wrong?

Hi there- I created a model that will classify up to 5 classes from a single image. The model supposedly works well and gets ~90% accuracy after 5 epochs.

The problem is using learn.predict(). It seems only able to identify images that are very similar to the ones in the training set. Even more startling is that the model finds 4 of the classes doing learn.predict() on a completely blank image! This doesn’t make sense to me. I am guessing that the model is just severely overfitted. Is there any way to fix this?

I’m using 500 images with each having an average of 3 classes. Is my dataset just too small?

It’s finding all four as we take an argmax for all the probabilities. You told your model to identify four classes, it will figure out from those classes which it fits into best.

How similar were your test images to your training set?

1 Like

Is there any way to have my model not find any if there aren’t any in the image? There are a few images in my training set that have nothing to identify.

My test images are very similar to the training set, they are being split by split_by_rand_pct() from the batch of photos.

Also: for the blank image and others, it would have a very high prediction value for classes that do not exist.Here’s an example output after doing learn.predict(blank_img.jpg) :
tensor([0.9909, 0.9978, 0.0101, 0.9812, 0.9828])

Not particularly. You could have a no_image folder option where those live. I believe Jeremy mentions ideas in lesson 6 or 7.

Understood. This model will really only be used on images similar to that it was trained on, with a few outliers that have nothing to identify. I’ll handle those cases manually. So, I won’t worry too much.

Thank you!!