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

MinMaxMetric for wrapping other metrics #49

Closed
janhenriklambrechts opened this issue Mar 12, 2021 · 12 comments · Fixed by #556
Closed

MinMaxMetric for wrapping other metrics #49

janhenriklambrechts opened this issue Mar 12, 2021 · 12 comments · Fixed by #556
Assignees
Labels
enhancement New feature or request New metric

Comments

@janhenriklambrechts
Copy link
Contributor

🚀 Feature

Motivation

  • MinMaxMetric is a metric that simply wraps another metric (e.g.val_acc) and creates a new metric that tracks the min, max or both values of val_acc.

Pitch

  • I personally use it to quickly see the max_val_acc of a complete experiment in TensorBoard (instead of going through the graph manually to find the max value) but I can see other usecases as well.
  • It was discussed in the PL Slack here and clearly resonated with more users

Additional context

  • Happy to submit a PR for this feature, as I do have already a (incomplete) MaxMetric code implemented here
@janhenriklambrechts janhenriklambrechts added enhancement New feature or request help wanted Extra attention is needed labels Mar 12, 2021
@github-actions
Copy link

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

@SkafteNicki
Copy link
Member

Hi @janhenriklambrechts are you still interested in sending a PR for this feature?

@janhenriklambrechts
Copy link
Contributor Author

Absolutely, you can assign it to me.
Think I will be able to start working on it in a few days :)

@SkafteNicki
Copy link
Member

@janhenriklambrechts Nice :]
Feel free to ping if you have any question (here or on slack).
If you need inspiration, then I have a open PR for another wrapper metric (#101) for creating bootstrapped versions of metrics.

@janhenriklambrechts
Copy link
Contributor Author

Thank you so much for the inspiration! Very useful!

@stale
Copy link

stale bot commented Jun 1, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 1, 2021
@janhenriklambrechts
Copy link
Contributor Author

Will only be able to work on it from beginning of July onward @SkafteNicki - is that OK?

@stale stale bot removed the wontfix label Jun 1, 2021
@Borda
Copy link
Member

Borda commented Jul 16, 2021

Will only be able to work on it from beginning of July onward @SkafteNicki - is that OK?

that is great! looking forward 🐰

@Borda Borda removed the help wanted Extra attention is needed label Sep 20, 2021
@SkafteNicki
Copy link
Member

@janhenriklambrechts any updates on this? :]

@janhenriklambrechts
Copy link
Contributor Author

Hi @SkafteNicki, completely lost track of this - I am starting this weekend! Thanks for pinging me :)

@SkafteNicki
Copy link
Member

@janhenriklambrechts no problem. Let me know if you need any help :]

@nils-werner
Copy link

nils-werner commented Mar 3, 2022

Right now I can't log() this if it is inside a MetricCollection(), right?

self.val_metric = torchmetrics.MetricCollection({
    'acc': torchmetrics.Accuracy(),
    'acc_best': torchmetrics.MinMaxMetric(torchmetrics.Accuracy())
})

because .compute() of the collection will return a nested dict

{'acc': tensor(0.9497), 'acc_best': {'raw': tensor(0.9595), 'max': tensor(1.), 'min': tensor(0.8281)}}

and I get an error message

ValueError: `self.log(val, {'acc': tensor(0.9497), 'acc_best': {'raw': tensor(0.9595), 'max': tensor(1.), 'min': tensor(0.8281)}})` was called, but nested dictionaries cannot be logged

It would be great if we could have a MaxMetric() wrapper that simply returns the max value, so that .compute() returns

{'acc': tensor(0.9497), 'acc_best': tensor(1.)}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request New metric
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants