# this class represents a learning rate schedular that decreases the learning rate by a given factor after the validation error has not fallen for a specified amount of epochs
importtorch
LR_Reduce_No_Train_Improvement=15
LR_Reduce_No_Val_Improvement=15
EARLY_STOP_LR_TOO_LOW=4e-6
# This learning rate scheduler works as follows: After 15 epochs of no improvement on the validation loss, the learning rate gets divided by a specified factor.
# Training terminates if the learning rate has fallen below 4E-6, then the best model on the validation loss (with highest validation accuracy) will be chosen as the final model.
logger.info('### After '+str(LR_Reduce_No_Train_Improvement)+' no train loss reduction => Best model loaded and LR reduced to '+str(self.currentLR)+' !')
logger.info('### After '+str(LR_Reduce_No_Val_Improvement)+' no val score improvement => Best model loaded and LR reduced to '+str(self.currentLR)+' !')