I ran something like this within a class that extends Module
:
getattr(self, "example", Parameter(torch.Tensor([size])).to(self.device))
Which should set a default class __dict__
value to the key “example.”
But when I print __dict__.keys()
, “example” isn’t added.
However, it is added as expected when I change the above to a non-Parameter:
getattr(self, "example", torch.Tensor([size]).to(self.device))
How can I set default params from Parameter
to a class attribute in __dict__
?