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

TorchMetrics: NaN-compatible variants for common Metrics functions [nan_(mean, sum, max)] #505

Closed
danieleschmidt opened this issue Sep 7, 2021 · 2 comments · Fixed by #506
Labels
enhancement New feature or request

Comments

@danieleschmidt
Copy link

🚀 Feature

Now that callables are no longer supported (see Lightning-AI/pytorch-lightning#8894), here's a feature request for TorchMetric support for these metrics.

pytorch_lightning.utilities.exceptions.MisconfigurationException: Only self.log(..., reduce_fx={min,max,mean,sum})are currently supported. Please, open an issue inhttps://github.com/PyTorchLightning/pytorch-lightning/issues`. Found: <function nanmean at 0x7fa4b394a9e0>
`

Motivation

I'm currently working on a multitask learning problem, where some tasks include missing labels for some of the tasks. As a result, some batches contain nans for specific tasks. I thus require a custom NaNMean torchmetrics class to aggregate batches properly - which I think many in the community will find useful.

Alternatives

Another solution would be to support callables for reduce_fx functions, as were supported previously (preferable), or provide support for skip_nan=bool when calling self.log(...)

@danieleschmidt danieleschmidt added enhancement New feature or request help wanted Extra attention is needed labels Sep 7, 2021
@github-actions
Copy link

github-actions bot commented Sep 7, 2021

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

@SkafteNicki
Copy link
Member

Hi @danieleschmidt,
Thanks for raising this issue. I created PR #506 that introduces a couple of aggregation metrics (sum, mean, max, min, cat) that can all deal with with nan input in multiple ways. Please take a look and comment if anything is missing.

@Borda Borda removed the help wanted Extra attention is needed label Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants