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

Small fix for NTXentLoss with no negative pairs #272

Closed
stephantul opened this issue Feb 2, 2021 · 1 comment
Closed

Small fix for NTXentLoss with no negative pairs #272

stephantul opened this issue Feb 2, 2021 · 1 comment
Labels
bug Something isn't working fixed in dev branch

Comments

@stephantul
Copy link

stephantul commented Feb 2, 2021

If all instances in a single batch have the same class, the NTXentLoss crashes with an uninformative warning:

AttributeError: 'list' object has no attribute 'dtype'

This is because this line assigns an empty list to neg_pairs if there are no negative pairs.
This crash can be avoided by moving the check for dtype in NTXentLoss (i.e., this line) a bit down, so it is enclosed by the if statement.

Should be a rare occurrence anyway, but I'd thought I'd signal it nonetheless 🐱

I can do a PR if you'd like, but maybe this is such a small fix that it doesn't need a separate PR

@KevinMusgrave KevinMusgrave added the bug Something isn't working label Feb 3, 2021
@KevinMusgrave
Copy link
Owner

Thanks for finding this bug. I've fixed it in the latest commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in dev branch
Projects
None yet
Development

No branches or pull requests

2 participants