'How to import TensorMetric in pytorch lighting?

I want to import TensorMetric :

from pytorch_lightning.metrics.metric import TensorMetric

The program throws an exception:

ModuleNotFoundError: No module named 'pytorch_lightning.metrics'

My environment is:

  • Python 3.8.13
  • tokenizers==0.9.2
  • torch==1.5.1
  • transformers==3.4.0
  • pytorch-lightning==0.9.0
  • tensorboard==2.2.0


Solution 1:[1]

0.9 is a very old version of Lightning and a lot has changed/improved since then. I would recommend you to use the latest version of PyTorch Lightning (1.6).

Also, we have metrics as a separate library now TorchMetrics.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aniket Maurya