5
$\begingroup$

I am trying to train a Siamese network for an application very similar to this and this. From what I have read about training Siamese networks dissimilar pairs of images outnumber the similar pairs and obviously so. In the papers I have linked to, the authors talk about a 1:20 ratio for similar to dissimilar pairs, i.e., for every similar pair of images, the training set consists of 20 dissimilar pairs. If I have understood it correctly, for a batch size of 64, my batch will consist of 3 similar pairs and the corresponding 20 dissimilar pairs for each of the similar pair.

I implemented the same in Keras, and the network overfits from the very first epoch. I have approximately 6000 similar pairs of images and I am generating the dissimilar pairs randomly. How do I reduce the overfitting? Any tips would help.

NOTE: I am using the last two Inception modules of Inception V3 to train my data. EDIT: We managed to fix this issue with getting more training data, and using a network pretrained on a very similar task.

$\endgroup$
2
  • $\begingroup$ How much are you overfitting? What is the drop in evaluation metrics between training and test? $\endgroup$ Oct 5 '18 at 13:15
  • $\begingroup$ If I train with a 1:1 ratio between similar and dissimilar images, with the negative samples selected randomly on the fly, the train loss goes down to 0.15 within 20 epochs. Test loss fluctuates randomly. I think this is because of the random selection of the negative pairs. On the other hand, if I increase the ratio between similar and dissimilar pairs. The train loss goes down to almost 0 within 5 epochs, whereas the val (test) loss is stuck at 1 and goes upto 7 if I let the network train for 10 epochs. $\endgroup$
    – Raghuram
    Oct 11 '18 at 2:51
1
$\begingroup$

The most common way to reduce overfitting in neural networks in your case are:

  1. Dropout - Randomly removing connections during training
  2. Data Augmentation - Creating variations in data, such as rotating or flipping images
$\endgroup$
2
  • $\begingroup$ I am doing the things you suggested. Not helping. Increased dropout from 0.5 to 0.9, to see if it would help. Did not help much. In my question, I linked to a few papers. All these papers claim to use a 1:20 ratio between similar to dissimilar pairs. Does that help in any way? Wouldn't that cause overfitting? On the other hand, if that is not done, the network doesn't learn enough of negative examples. $\endgroup$
    – Raghuram
    Oct 11 '18 at 2:39
  • $\begingroup$ I did data augmentation also. Rotate, translate, random crop $\endgroup$
    – Raghuram
    Oct 11 '18 at 2:53
0
$\begingroup$

Since you say that the network is overfitting right from the first epoch, I would suggest you to use simpler architectures than Inception V3 network. Data augmentation, and dropout would work if the overfitting is in a low to medium range. But if it is heavily overfitting right from the first epoch, those techniques just wouldn't work.

$\endgroup$

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.