Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add triplet margin for distance functions in TripletEvaluator #2862

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

zivicmilos
Copy link

@zivicmilos zivicmilos commented Jul 25, 2024

Problem:

Triplet margin exists in TripletLoss but does not exist in TripletEvaluator.


Motivation:

When evaluating the model using TripletEvaluator during, for example, the training it would be a nice thing to have a piece of information not only if the negative is further away from the anchor than the positive, but also if it is further away from the anchor by some predefined margin. Because the triplet evaluator uses 4 different distance metrics, we would need an option for each one, so 4 different margins for each of them.


Solution:

In the commit, I implemented exactly that, option for setting the margin for each distance function (or any subset of them). It is an optional argument to the class constructor, so it can be called perfectly the same as previously, with the difference that now you have more flexibility in setting how far away you want your negative and positive to be for evaluation.


PS. I can also write some evaluator tests, both for TripletEvaluator with and without the margin.

PPS. I ran a make check, so the code follows coding guidelines.


@zivicmilos zivicmilos changed the title Add triplet margin for distance functions Add triplet margin for distance functions in TripletEvaluator Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants