Image-Text-Embedding icon indicating copy to clipboard operation
Image-Text-Embedding copied to clipboard

How to avoid overfitting

Open Fly2flies opened this issue 6 years ago • 1 comments

Hello, ZheDong, thanks for you sharing such a good work. I want to reproduce it in Pytorch,but I'm sorry that I encountered the overfitting problem. To get the results quickly, I randomly choose 10,000 samples as traindata and 1,000 as valdata, 1,000 as testdata separately. Finally I got about 100% recall@5 on the training set while only half of it on the val data. And I'm a fresh man to ImageTextEmbedding,could you share some solutions to that. I guess there are relevant reasons:

  1. Data normalization. I don't compute the mean and var of train_data explicitly, and just divide it by 255, subtract 0.5, and thendivide it by 0.5

  2. L2 regularization. I just use the 1e-5 regularization intensity

  3. The complexity of classifier. After generator, I add a classifier with a softmax layer directly. Whether more fully connection layers can slow down the fitting of the training set

Finally, I want to ask how to mine the hard triplet online in Pytorch efficiently.

Thanks.

Fly2flies avatar Dec 11 '19 02:12 Fly2flies

Thank you @EternallyTruth

  • Have you tried to add dropout layer?
  • You may consider to use larger learning rate.
  • You may check my another repo about triplet loss in Pytorch (https://github.com/layumi/Person-reID-triplet-loss).

layumi avatar Dec 11 '19 09:12 layumi