pytorch_tabular
pytorch_tabular copied to clipboard
Import error
When I import
from pytorch_tabular import TabularModel
catch error
14 import random
15
---> 16 from pytorch_tabular import TabularModel
17 from pytorch_tabular.models import CategoryEmbeddingModelConfig, NodeConfig, NODEModel
18 from pytorch_tabular.config import DataConfig, OptimizerConfig, TrainerConfig, ExperimentConfig, ModelConfig
[/usr/local/lib/python3.7/dist-packages/pytorch_lightning/metrics/utils.py](https://localhost:8080/#) in <module>()
20 from torchmetrics.utilities.data import dim_zero_mean as _dim_zero_mean
21 from torchmetrics.utilities.data import dim_zero_sum as _dim_zero_sum
---> 22 from torchmetrics.utilities.data import get_num_classes as _get_num_classes
23 from torchmetrics.utilities.data import select_topk as _select_topk
24 from torchmetrics.utilities.data import to_categorical as _to_categorical
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' (/usr/local/lib/python3.7/dist-packages/torchmetrics/utilities/data.py)
How can I fix it?
This looks like a version issue... What is the version of torchmetrics you have installed?
I am facing the same issue, using torchmetrics version 0.8.2
Looks like an issue with PyTorch Lightning and torchmetrics version incompatibility... Until the lightning team fixes this (or I change the versions of both), downgrading to torchmetrics>=0.7.0,<=0.7.3 seems to work for some others who have faced similar issue.
This commit in another library which uses lightning and torchmetrics
Yes I downgraded torchmetrics to 0.3.2 and it worked, thanks
Check out #84 also, as torchmetrics==0.5 also worked for some.
pip install torchmetrics==0.5. I have done this, it worked for me
Since everyone has found a solution, I will close this issue. I will reopen if I have more questions in the future