0
$\begingroup$

I'm working for the first time on my own with a convolutional neural network, and I'm kind of stuck with the same results since the very beginning.

My model is built with Pytorch and it has the following structure:

Convolutional layer 1 -> Convolutional layer 2 -> Convolutional layer 3 -> MLP (input-hidden-output)

I'm trying to use this model for a binary classification task. I have a dataset of 2482 images and as far as I know (from some code that I found) my model has 7010 trainable parameters. Since this size is not enough for training the model from scratch, I'm performing data augmentation in the train split (I'm splitting 90-10%) obtaining 46554 images, which I think it should be enough for a decent training.

The problem I'm facing is, with that setup my validation accuracy is not increasing. Moreover, after a few epochs it decreases. Training accuracy increases, so it looks like overfitting but, is this really overfitting? Is a model with 7010 parameters able to overfit a dataset with 46554 images?

Any comment/link/reference is appreciated. Thanks in advance

$\endgroup$

1 Answer 1

0
$\begingroup$

Even with data augmentation 90% of 2482 does not magically become 46554. Data augmentation increases the value of each image, maybe even so that one is worth a few images, but it's still worth less than 46554 completely unrelated images would be worth.

The kind of model you have could certainly be overfitting in your situation. However, I would also look at the training loss and validation loss, not just accuracy, because accuracy uses very little information per image (i.e. just 1 or 0, while whatever loss function you are using will take into account that predicting 0.9 for a 1 outcome is better than predicting 0.51). I.e. accuracy is quite a noisy thing to look at that can jump around in a misleading way due to the very small amount of information it captures.

Other ways of combatting overfitting besides data augmentation include various forms of regularization such as dropout or weight decay. Other promising ideas could include transfer learning from other types of images or unsupervised learning on a large amount of unlabeled images (if you have such images), even if you want to use a smaller CNN than those that are available pre-trained you could pre-train yours on ImageNet or distill a larger CNN trained on ImageNet into your smaller one.

$\endgroup$
1
  • $\begingroup$ First of all, thanks a lot for your explanation. It is the first time I get an answer here :) I didn't want to make the question longer, so I didn't include some more info. I'm looking also at losses; in fact those are my two training metrics, accuracy and loss (in both training and validation dataset). Other issue that I encountered is my validation loss going higher than 1, which I've read that is a bad situation. About data augmentation, I don't really get what you mean with "increases the value of each image". After augmentation, I literally have 46554 "different" images. $\endgroup$ Commented Dec 14, 2022 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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