src/core/util.py
def on_epoch_end(self, epoch, logs=None):
        '''
        Per epoch logic for managing learning rate and early stopping
        '''
        stop_training = False
        # check if we need to stop or increase scheduler stage
        if isinstance(logs, dict):
            loss = logs['val_loss']
        else:
            loss = logs
        if loss <= self.best_loss:
            self.best_loss = loss
            self.wait = 0
        else:
            self.wait += 1
            if self.wait > self.patience:
                self.scheduler_stage += 1
                self.wait = 0

        # calculate and set learning rate
        lr = self.lr * np.power(self.drop, self.scheduler_stage)
        K.set_value(self.lr_tensor, lr)

        # built in stopping if lr is way too small
        if lr <= 1e-7:
            stop_training = True

        # for keras
        if hasattr(self, 'model') and self.model is not None:
            self.model.stop_training = stop_training

        return stop_training

        Per epoch logic for managing learning rate and early stopping
        
Per epoch logic for managing learning rate and early stopping
Per epoch logic for managing learning rate and early stopping
def on_epoch_end(self, epoch, logs=None):
        stop_training = False
        if isinstance(logs, dict):
            loss = logs['val_loss']
        else:
            loss = logs
        if loss <= self.best_loss:
            self.best_loss = loss
            self.wait = 0
        else:
            self.wait += 1
            if self.wait > self.patience:
                self.scheduler_stage += 1
                self.wait = 0
        lr = self.lr * np.power(self.drop, self.scheduler_stage)
        K.set_value(self.lr_tensor, lr)
        if lr <= 1e-7:
            stop_training = True
        if hasattr(self, 'model') and self.model is not None:
            self.model.stop_training = stop_training
        return stop_training
def on_epoch_end ( self , epoch , logs = None ) : stop_training = False if isinstance ( logs , dict ) : loss = logs [ 'val_loss' ] else : loss = logs if loss <= self . best_loss : self . best_loss = loss self . wait = 0 else : self . wait += 1 if self . wait > self . patience : self . scheduler_stage += 1 self . wait = 0 lr = self . lr * np . power ( self . drop , self . scheduler_stage ) K . set_value ( self . lr_tensor , lr ) if lr <= 1e-7 : stop_training = True if hasattr ( self , 'model' ) and self . model is not None : self . model . stop_training = stop_training return stop_training
Per epoch logic for managing learning rate and early stopping
Per epoch logic for managing learning rate and early stopping
'''
        Per epoch logic for managing learning rate and early stopping
        ''' # check if we need to stop or increase scheduler stage # calculate and set learning rate # built in stopping if lr is way too small # for keras
self
epoch
logs