Lightning-AI / torchmetrics

Machine learning metrics for distributed, scalable PyTorch applications.
https://lightning.ai/docs/torchmetrics/
Apache License 2.0
2.14k stars 408 forks source link

TypeError: `NoTrainInceptionV3.__init__()` takes 1 positional argument but 4 were given #2130

Closed segalinc closed 1 year ago

segalinc commented 1 year ago

Hello,

trying to init NoTrainInceptionV3 with latest version

    feature_list=["2048"]
    inception = NoTrainInceptionV3(name="inception-v3-compat", features_list=feature_list)

but I get

   445     raise TypeError("{}.__init__() got an unexpected keyword argument '{}'"
    446                     "".format(type(self).__name__, next(iter(kwargs))))
    448 if self.call_super_init is False and bool(args):
--> 449     raise TypeError("{}.__init__() takes 1 positional argument but {} were"
    450                     " given".format(type(self).__name__, len(args) + 1))
    452 """
    453 Calls super().__setattr__('a', a) instead of the typical self.a = a
    454 to avoid Module.__setattr__ overhead. Module's __setattr__ has special
    455 handling for parameters, submodules, and buffers but simply calls into
    456 super().__setattr__ for all other attributes.
    457 """
    458 super().__setattr__('training', True)

TypeError: NoTrainInceptionV3.__init__() takes 1 positional argument but 4 were given
Borda commented 1 year ago

@segalinc could you pls chare more details like what package versions you are using?

segalinc commented 1 year ago

torchmetrics @ git+https://github.com/Lightning-AI/torchmetrics.git@0d7d6c7ccfedbb4941dfc55e65bbfca88506b2dc

I also tried with version 1.1.12 and 1.2.0

I am using python not conda

SkafteNicki commented 1 year ago

I assume it's because you do not have torch-fidelity installed and it therefore is a dummy class that is trying to be initialized which does only take one argument. @segalinc could you please confirm if this is true? @Borda we should probably guard against this in some way

segalinc commented 1 year ago

Yes installing torch-fidelity solved the problem Maybe adding this note in the readme.md or as requirements can help thank you