callbacks=[LRA(model=model,patience=patience,stoppatience=stoppatience,…
- User
callbacks=[LRA(model=model,patience=patience,stop_patience=stop_patience, threshold=threshold, factor=factor,dwell=dwell,model_name= model_name, freeze=freeze, initial_epoch=0 )] --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[26], line 8 6 dwell=True # experimental, if True and monitored metric does not improve on current epoch set modelweights back to weights of previous epoch 7 freeze=False # if true free weights of the base model ----> 8 callbacks=[LRA(model=model,patience=patience,stop_patience=stop_patience, threshold=threshold, 9 factor=factor,dwell=dwell,model_name= model_name, freeze=freeze, initial_epoch=0 )] 10 LRA.tepochs=epochs # used to determine value of last epoch for printing 11 history=model.fit(x=train_gen, epochs=epochs, callbacks=callbacks, verbose=0, validation_data=valid_gen, 12 validation_steps=None, shuffle=False, initial_epoch=0)
Cell In[25], line 8, in LRA.init(self, model, patience, stop_patience, threshold, factor, dwell, model_name, freeze, initial_epoch) 6 def init(self,model, patience,stop_patience, threshold, factor, dwell, model_name, freeze, initial_epoch): 7 super(LRA, self).init() ----> 8 self.model=model 9 self.patience=patience # specifies how many epochs without improvement before learning rate is adjusted 10 self.stop_patience=stop_patience
AttributeError: can't set attribute 'model'
- Assistant
The error message you're encountering,
AttributeError: can't set attribute 'model', suggests that within the class, there's an issue with setting the model attribute when initializing an instance of this class. This could happen for a few reasons, but commonly because there's a property within the class named that doesn't allow direct assignment without a setter. - User
- Assistant
Given the updated code for your class, which is a custom callback inheriting from , it appears that the original issue you were facing regarding the inability to set the attribute should typically not be present. This could suggest the error was possibly related to something outside this provided snippet or a misunderstanding in the initial problem description.