Dynamic learning rate in training - 培训中的动态学习率

时间:2021-12-15 00:08:42

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