fmenat / PyLearningCrowds

Some learning from crowds methods implemented in Python
6 stars 1 forks source link

AttributeError: Can't set the attribute "name", likely because it conflicts with an existing read-only @property of the object. Please choose a different name. #3

Closed PepijndeReus closed 8 months ago

PepijndeReus commented 8 months ago

When running cell 36 of the Label me tutorial I some across the following error:


AttributeError Traceback (most recent call last) File ~/anaconda3/lib/python3.10/site-packages/keras/src/engine/base_layer.py:3153, in Layer.setattr(self, name, value) 3152 try: -> 3153 super(tf.internal.tracking.AutoTrackable, self).setattr( 3154 name, value 3155 ) 3156 except AttributeError:

AttributeError: can't set attribute 'name'

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last) Cell In[36], line 6 3 #R_model = Raykar(init_Z="model", priors='laplace', n_init_Z=5) 5 args = {'epochs':1, 'batch_size':BATCH_SIZE, 'optimizer':OPT} ----> 6 R_model.set_model(model_R, **args)

File ~/Downloads/clone/codeE/methods.py:324, in Super_ModelInf.set_model(self, model, optimizer, epochs, batch_size, lib_model) 322 if self.base_model_lib == "keras": 323 self.base_model.compile(optimizer=self.optimizer, loss='categorical_crossentropy') --> 324 self.base_model.name = "base_model_z" 325 self.max_Bsize_base = estimate_batch_size(self.base_model) 327 elif self.base_model_lib =="sklearn":

File ~/anaconda3/lib/python3.10/site-packages/keras/src/engine/training.py:390, in Model.setattr(self, name, value) 383 except AttributeError: 384 raise RuntimeError( 385 "It looks like you are subclassing Model and you " 386 "forgot to call super().__init__()." 387 " Always start with this line." 388 ) --> 390 super().setattr(name, value)

File ~/anaconda3/lib/python3.10/site-packages/keras/src/engine/base_layer.py:3157, in Layer.setattr(self, name, value) 3153 super(tf.internal.tracking.AutoTrackable, self).setattr( 3154 name, value 3155 ) 3156 except AttributeError: -> 3157 raise AttributeError( 3158 ( 3159 'Can\'t set the attribute "{}", likely because it ' 3160 "conflicts with an existing read-only @property of the " 3161 "object. Please choose a different name." 3162 ).format(name) 3163 ) 3164 return 3166 # Wraps data structures in Trackable, unwraps NoDependency objects.

AttributeError: Can't set the attribute "name", likely because it conflicts with an existing read-only @property of the object. Please choose a different name.

fmenat commented 8 months ago

Thanks for the comments! I fixed the issue in the recent commit.

Best!