Lightning-AI / torchmetrics

Torchmetrics - Machine learning metrics for distributed, scalable PyTorch applications.

Home Page:https://lightning.ai/docs/torchmetrics/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`MultitaskWrapper` still cannot be logged

fourson opened this issue Β· comments

πŸ› Bug

in torchmetrics 1.3.0.post0 MultitaskWrapper still cannot be logged once the metrics are MetricCollection.

To Reproduce

self.log_dict(self.val_metrics)

where self.val_metrics is a MultitaskWrapper defined as

self.val_metrics = MultitaskWrapper({
            'ImgMet': MetricCollection({
                'PSNR': PeakSignalNoiseRatio(data_range=1.0),
                'SSIM': StructuralSimilarityIndexMeasure(data_range=1.0),
            }),
        # add other things to measure later
        })

See above, which can be pasted in the test sample.
error msg (which is from the self.log invoked by self.log_dict):

ValueError: `self.log(ImgMet, MetricCollection(
  (PSNR): PeakSignalNoiseRatio()
  (SSIM): StructuralSimilarityIndexMeasure()
))` was called, but `MetricCollection` values cannot be logged

Expected behavior

Environment

The newest version for all.

I am trying to log:
self.log_dict({'output_1 Loss': {'VALIDATION': 0}, 'output_2 Loss': {'VALIDATION': 0}})
But I get the error:

ValueError: `self.log(output_1 Loss, {'VALIDATION': 0})` was called, but `dict` values cannot be logged

Running pytorch-lightning==2.2.0.post0 and torchmetrics-0.10.0.
Is this related? How can I solve?

@fourson did you find a temporary fix?