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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom callable is ignored in retrieval metric aggregation #2363

Closed
fschlatt opened this issue Feb 8, 2024 · 1 comment 路 Fixed by #2364
Closed

Custom callable is ignored in retrieval metric aggregation #2363

fschlatt opened this issue Feb 8, 2024 · 1 comment 路 Fixed by #2364
Labels
bug / fix Something isn't working help wanted Extra attention is needed

Comments

@fschlatt
Copy link
Contributor

fschlatt commented Feb 8, 2024

馃悰 Bug

When passing a custom aggregation to any RetrievalMetric, the callable is ignored. There is a bug in the retrieval aggregation function that defaults to using the maximum of the values by default

To Reproduce

The following custom aggregation should output the tensor of values without aggregation but returns 1, the max of the values.

>>> from torchmetrics.retrieval import RetrievalNormalizedDCG
>>> indexes = tensor([0, 0, 0, 1, 1, 1, 1])
>>> preds = tensor([0.2, 0.3, 0.5, 0.1, 0.3, 0.5, 0.2])
>>> target = tensor([False, False, True, False, True, False, True])
>>> ndcg = RetrievalNormalizedDCG(aggregation=lambda x, dim: x)
>>> print(ndcg(preds, target, indexes=indexes))
tensor(1.)
>>> ndcg = RetrievalNormalizedDCG(aggregation="max")
>>> print(ndcg(preds, target, indexes=indexes))
tensor(1.)
>>> ndcg = RetrievalNormalizedDCG()
>>> print(ndcg(preds, target, indexes=indexes))
tensor(0.8467)
@fschlatt fschlatt added bug / fix Something isn't working help wanted Extra attention is needed labels Feb 8, 2024
Copy link

github-actions bot commented Feb 8, 2024

Hi! thanks for your contribution!, great first issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug / fix Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant