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

Error when providing superclass arguments as kwargs #1068

Closed
jlcsilva opened this issue Jun 6, 2022 · 1 comment · Fixed by #1069
Closed

Error when providing superclass arguments as kwargs #1068

jlcsilva opened this issue Jun 6, 2022 · 1 comment · Fixed by #1069
Labels
bug / fix Something isn't working help wanted Extra attention is needed

Comments

@jlcsilva
Copy link
Contributor

jlcsilva commented Jun 6, 2022

🐛 Bug

When some classes are instantiated with superclass arguments as kwargs, the superclass constructor receives multiple values for these arguments and instantiation fails with an error like:

TypeError: torchmetrics.classification.stat_scores.StatScores.__init__() got multiple values for keyword argument 'reduce'

This happens for the following classes:

  • Accuracy
  • Dice
  • JaccardIndex
  • Precision
  • Recall
  • Specificity

To Reproduce

Instantiate Accuracy, Dice, Precision, Recall or Specificity specifying the argument reduce or mdmc_reduce as kwarg, or the class JaccardIndex with the normalize argument as kwarg.

Code sample

Accuracy(reduce='micro')
Accuracy(mdmc_reduce='global')
Dice(reduce='micro')
Dice(mdmc_reduce='global')
Precision(reduce='micro')
Precision(mdmc_reduce='global')
Recall(reduce='micro')
Recall(mdmc_reduce='global')
Specificity(reduce='micro')
Specificity(mdmc_reduce='global')
JaccardIndex(num_classes=1, normalize='true')

Expected behavior

The class should be instantiated prioritizing values provided as kwargs, instead of default values generated inside the constructor.

Environment

  • TorchMetrics 0.9.0 built from source
  • Python 3.10.4 & PyTorch 1.11.0
  • WSL Ubuntu 20.04
@jlcsilva jlcsilva added bug / fix Something isn't working help wanted Extra attention is needed labels Jun 6, 2022
@github-actions
Copy link

github-actions bot commented Jun 6, 2022

Hi! thanks for your contribution!, great first issue!

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