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

clone() throwing exception on single Metric or MetricCollection #1249

Closed
omerferhatt opened this issue Oct 5, 2022 · 0 comments · Fixed by #1250
Closed

clone() throwing exception on single Metric or MetricCollection #1249

omerferhatt opened this issue Oct 5, 2022 · 0 comments · Fixed by #1250
Labels
bug / fix Something isn't working help wanted Extra attention is needed

Comments

@omerferhatt
Copy link

🐛 Bug

clone() functionality not working and raising argument error.

To Reproduce

>>> import torchmetrics as tm
>>> iou_train = tm.JaccardIndex(num_classes=3, average="none", mdmc_average="samplewise")
>>> iou_val = iou_train.clone()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/.../.venv/lib/python3.8/site-packages/torchmetrics/metric.py", line 569, in clone
    return deepcopy(self)
  File "/usr/lib/python3.8/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/usr/lib/python3.8/copy.py", line 264, in _reconstruct
    y = func(*args)
  File "/usr/lib/python3.8/copyreg.py", line 91, in __newobj__
    return cls.__new__(cls, *args)
TypeError: __new__() missing 1 required positional argument: 'num_classes

Expected behavior

It should create a new object with given template

Environment

  • TorchMetrics version (and how you installed TM, e.g. conda, pip, build from source):
    • torchmetrics==0.10.0 (pip)
  • Python & PyTorch Version (e.g., 1.0):
    • python==3.8.10
    • torch==1.12.1+cu116
  • Any other relevant information such as OS (e.g., Linux):
    • uname
Linux hostname 5.15.0-1018-gcp #24~20.04.1-Ubuntu SMP Mon Sep 12 06:14:01 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  • nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Tue_Mar__8_18:18:20_PST_2022
Cuda compilation tools, release 11.6, V11.6.124
Build cuda_11.6.r11.6/compiler.31057947_0

Additional context

P.S. When I downgrade to version ~0.9 , errors not occur anymore and works expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug / fix Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant