Fix kwargs not passed to SubCenterArcFaceLoss#746
Merged
KevinMusgrave merged 2 commits intoKevinMusgrave:devfrom Apr 11, 2025
Merged
Fix kwargs not passed to SubCenterArcFaceLoss#746KevinMusgrave merged 2 commits intoKevinMusgrave:devfrom
KevinMusgrave merged 2 commits intoKevinMusgrave:devfrom
Conversation
Owner
|
Thanks! Seems reasonable. Can you add your example to the tests here: https://github.com/KevinMusgrave/pytorch-metric-learning/blob/master/tests/losses/test_subcenter_arcface_loss.py Something like this should be sufficient I think: from pytorch_metric_learning.reducers import DoNothingReducer
def test_reducer(self):
arcfaceloss = SubCenterArcFaceLoss(
num_classes=10,
sub_centers=3,
embedding_size=64,
reducer=DoNothingReducer(),
)
emb = torch.randn(4, 64)
result = arcfaceloss(emb, torch.arange(4))
self.assertTrue(isinstance(result, dict)) |
Contributor
Author
|
Hi @KevinMusgrave, |
Owner
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
**kwargsare not passed into__init__ofSubCenterArcFaceLoss.This leads to problems, for example with
reducers, which have no effect when passed.Example bug:
The fix includes the use of
deepcopyto ensure no reference problems occur when deleting the keys form**kwargs, which is necessary otherwise duplicate keys are passed into__init__. But perhaps it can be done more elegantly.