-
Notifications
You must be signed in to change notification settings - Fork 408
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
Logging a class-wise metric with ClasswiseWrapper #2756
Comments
Hi! thanks for your contribution!, great first issue! |
Was fixed in this PR: #2720 torchmetrics/tests/integrations/test_lightning.py Lines 509 to 574 in 8cf181f
Please wait for the fix to be released in the next release of torchmetrics or alternatively you can install directly from master:
Closing issue. |
@SkafteNicki Thank you ! self.train_metrics.update(preds, target)
batch_values = self.train_metrics.compute()
self.log_dict(batch_values, on_step=True, on_epoch=False) I'm not too sure how the On my side, I am doing: def training_step(self, batch, batch_idx):
logits, y, loss = self.step(batch)
self.log("train/loss", loss, on_step=True, on_epoch=True)
metric_dict = self.train_metrics(logits, y)
metric_dict = {f"{key}_step": value for key, value in metric_dict.items()}
self.log_dict(metric_dict)
def on_train_epoch_end(self):
train_metrics = self.train_metrics.compute()
train_metrics = {f"{key}_epoch": value for key, value in train_metrics.items()}
self.log_dict(train_metrics)
self.train_metrics.reset() Am I doing things correctly here ? Should I specify |
Hi @patrontheo, you are completely right I made a mistake in the PR. The |
@SkafteNicki Thanks a lot for the clarification ! :) |
Discussed in #1462
Originally posted by blazejdolicki January 26, 2023
Hey everyone, I am trying to log the metric Dice(average="none") to Neptune using torchmetrics and pytorch lightning. Because this is a class-wise metric, it returns a tensor of shape (num_classes) instead of a scalar which makes it a bit complicated. I found this issue and PR which were supposed to solve the problem, but when I try to use them, I am still getting an error. I would appreciate any hints whether I am doing something wrong in my code or this is just not supported :)
My code looks something like this:
The error:
The text was updated successfully, but these errors were encountered: