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

Triplet loss finetuning? #230

Open
Davidc2525 opened this issue Jun 3, 2024 · 2 comments
Open

Triplet loss finetuning? #230

Davidc2525 opened this issue Jun 3, 2024 · 2 comments

Comments

@Davidc2525
Copy link

Can you leave an example of how to do finetuning with triplet loss?

@Davidc2525 Davidc2525 changed the title Tripleta loss finetuning? Triplet loss finetuning? Jun 3, 2024
@ihsingh2
Copy link

ihsingh2 commented Jul 6, 2024

Hey,

Given a list of triplets, you need to define a dataset for them. You can refer to these two examples to get an idea of how to define custom datasets. Once that is done, you can setup a dataloader for this dataset, and use it in your training loop. You can use torch.nn.TripletMarginLoss for the loss function.

However, if you are using training.pass_epoch, do note that it expects to unpack a batch of single images at a time (see this). You will have to modify it to unpack a batch of tuple of three images and evaluate each image on the model individually, before passing on to the loss function.

Hope that helps!

@fn-hide
Copy link

fn-hide commented Aug 7, 2024

Any updates?

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

No branches or pull requests

3 participants