I am trying to import initiate a LightningModule class module, but for some reasons i unable to set hparams. However if i change the name to hparams2 it suddenly seems to work. I have no idea how and any feedback would be apricated,.
import pytorch_lightning as pl
class ImagenetTransferLearningWorks(pl.LightningModule):
def __init__(self, num_classes = 10):
super().__init__()
self.hparams2 =SimpleNamespace(
num_classes = num_classes
)
#self._create_network()
class ImagenetTransferLearning(pl.LightningModule):
def __init__(self, num_classes = 10):
super().__init__()
self.hparams =SimpleNamespace(
num_classes = num_classes
)
ImagenetTransferLearningWorks()
ImagenetTransferLearning()
results in the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<command-3180059140582422> in <module>
20
21 ImagenetTransferLearningWorks()
---> 22 ImagenetTransferLearning()
<command-3180059140582422> in __init__(self, num_classes)
14 def __init__(self, num_classes = 10):
15 super().__init__()
---> 16 self.hparams =SimpleNamespace(
17 num_classes = num_classes
18 )
/databricks/python/lib/python3.8/site-packages/torch/nn/modules/module.py in __setattr__(self, name, value)
1176 buffers[name] = value
1177 else:
-> 1178 object.__setattr__(self, name, value)
1179
1180 def __delattr__(self, name):
AttributeError: can't set attribute
I don't understand what goes wrong here, could someone please explain to me why this happens?
Thank you in advance,