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

Multi-labels #742

Open
lucamarini22 opened this issue Mar 19, 2025 · 1 comment
Open

Multi-labels #742

lucamarini22 opened this issue Mar 19, 2025 · 1 comment

Comments

@lucamarini22
Copy link

lucamarini22 commented Mar 19, 2025

Hello! First of all, thanks for this awesome library.

Is there a way to pass to a loss function a matrix of 0 and 1 (or False and True) of every possible pair instead of passing the class labels?

I'm asking this to manage the case where a sample belongs to multiple classes.

@KevinMusgrave
Copy link
Owner

KevinMusgrave commented Mar 23, 2025

For contrastive losses (ContrastiveLoss, NTXentLoss etc.) you can omit the labels and pass in indices_tuple:

loss_fn = ContrastiveLoss()
loss = loss_fn(embeddings, indices_tuple=indices_tuple)

Here's an example of how you can specify positive and negative pairs using indices_tuple: #435 (comment)

The discussion in the link is about the output of a miner, but you don't have to use a miner. You can manually create the indices_tuple yourself.

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

2 participants