c100rczyk / Team_project_PWR

This is team project implemented as part of the IT specialization in the field of Automation and Robotics, in cooperate with company. Main technologies are: Computer Vision. Language: Python.
MIT License
2 stars 0 forks source link

How to improve our loss function #26

Open c100rczyk opened 5 months ago

c100rczyk commented 5 months ago

https://arxiv.org/abs/1503.03832

c100rczyk commented 5 months ago

Important information from the work:

  1. It is crucial to select hard triplets, that are active and can therefore contribute to improving the model.
c100rczyk commented 5 months ago

Using hard examples (hard positives and hard negatives) in model training is crucial for achieving better convergence and overall performance. Hard examples present the model with challenging cases, forcing it to learn subtle differences and improve its decision boundaries. This leads to faster learning and better generalization to unseen data.

c100rczyk commented 5 months ago
  1. Use hard positive and hard negative images in triplets. Hard positive argmax_xip||f(xia) - f(xip)||^2 Hard negative argmin_xin ||f(xia) - f(xin)||^2 Two possible choices:
c100rczyk commented 5 months ago

Important to note: Hard negatives examples can lead to bad local minima of model. Model can collapsed. SO: it is important (especially on early phase of training) to choose such negatives that: distance_between(anchor, positive) < distance_between(anchor, negative)

c100rczyk commented 5 months ago

Proposition: In each batch find some hard positives examples (for example):

And get most hard negatives to the triplets that meet the condition :

Train only on that examples in each batch

c100rczyk commented 4 months ago

Based on this we have maybe the answer (why sometimes it happend that our model did not learn). The accuracy top1 was 50%. So at the beginning model could get some hard negatives which had a strong negative impact on further learning and the model became blocked.

c100rczyk commented 4 months ago

Articles that i think will help with implementation: https://omoindrot.github.io/triplet-loss https://arxiv.org/abs/1703.07737 And repository: https://github.com/omoindrot/tensorflow-triplet-loss