omoindrot / tensorflow-triplet-loss

Implementation of triplet loss in TensorFlow
https://omoindrot.github.io/triplet-loss
MIT License
1.12k stars 283 forks source link

Advice on which loss to optimize #59

Closed sapan closed 3 years ago

sapan commented 3 years ago

First of all, great blog and an amazing piece of code. The question is related to the loss that one should optimize for.

So, it looks like it is difficult to assume that the loss as it is minimized currently would gradually decrease. In fact, I observed that after a few epochs, when only tough triplets are present in the valid set, the loss increases a bit. On the other hand, the fraction of valid triplets keeps decreasing (at least in my application).

So, how can we decide when (after how many epochs) to stop training? For instance, If I want to have an early stopping criteria, shall that be on the loss value or the fraction of valid triples?

omoindrot commented 3 years ago

Monitoring the fraction of valid triplets is more interesting because it will decrease during training as you say.

But the best metric to monitor (and base early stopping on) really depends on your application. If you are doing face recognition, then maybe the metric you want to monitor should be the ROC-AUC on a separate test set or something adapted.

sapan commented 3 years ago

Thanks for the suggestions, closing this.