Dynamic learning rate in training

I'm using keras 2.1.* and want to change the learning rate during training. I know about the schedule callback, but I don't use fit function and I don't have callbacks. I use train_on_batch. Is it possible in keras ?

Solution 1

If you use other functions like train_on_batch, you can change the learning rate with this way

From keras import backend as K

Old_lr = K.get_value(model.optimizer.lr)
New_lr = old_lr * 0.1   # change however you want 
K.set_value(model.optimizer.lr, new_lr)

github issue: https://github.com/keras-team/keras/issues/898

aipool discussion: https://ai-pool.com/d/dynamic_learning_rate_in_training