quaterion icon indicating copy to clipboard operation
quaterion copied to clipboard

[WIP] Implement XBM

Open monatis opened this issue 1 year ago • 1 comments

This is still WIP, so consider it as a draft for now.

Closes #163.

I'm adding commits after small refactoring and polishing comments. Will request a review afterwards.

monatis avatar Aug 10 '22 06:08 monatis

Deploy Preview for capable-unicorn-d5e336 ready!

Name Link
Latest commit 66fceb87cc2fb383395136d14954c6b49578be90
Latest deploy log https://app.netlify.com/sites/capable-unicorn-d5e336/deploys/62fe8ccd4c5ccd0008c5158f
Deploy Preview https://deploy-preview-171--capable-unicorn-d5e336.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Aug 10 '22 06:08 netlify[bot]

It's zero-size tensor (scalar), so regular equal and not-equal operators should work --we use torch.allclose and the similar to compare vectors and embeddings to avoid ambiguous meaning of comparing them.

monatis avatar Aug 16 '22 00:08 monatis

trying to compare xbm_loss and regular loss:

torch.random.manual_seed(42)
embeddings = torch.rand(64, 100)
groups = torch.randint(0, 10, (64,))

loss = TripletLoss(margin=1.0, mining="hard")

print(loss(embeddings, groups))
print(loss._compute_xbm_loss(embeddings, groups, embeddings, groups))

If I understand the approach right, loss and _compute_xbm_loss should give same result in this case, but in fact I got

tensor(1.5443)
tensor(50.5432)

Order of magnitude different. I am not sure how the implementation was validated and if this is an expected result, but in this case xbm weight constant is especially tricky to select.

generall avatar Aug 19 '22 18:08 generall