My CNN reaches over 95% accuracy on the training set.
But on the test set it drops below 40%.
The data comes from the same source.
I feel the model is memorizing instead of learning.
Why does my image classifier have very high training accuracy but terrible test accuracy?
Nishant MishraBegginer
This happens because the model is overfitting to the training data.
The network is learning specific pixel patterns instead of general features, so it performs well only on images it has already seen.
You need to increase generalization by adding data augmentation, dropout, and regularization:
transforms.RandomHorizontalFlip()
transforms.RandomRotation(10)
Also reduce model complexity or add weight decay in the optimizer.
Common mistakes:
Training on small datasets
Using too many layers
Not shuffling data
The practical takeaway is that high training accuracy without test accuracy means your CNN is memorizing, not understanding.