Created
January 26, 2021 17:22
-
-
Save ntakouris/e8a29d4883c4762ea22290c32338c755 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lr_scheduler(epoch, lr, warmup_epochs=15, decay_epochs=100, initial_lr=1e-6, base_lr=1e-3, min_lr=5e-5): | |
if epoch <= warmup_epochs: | |
pct = epoch / warmup_epochs | |
return ((base_lr - initial_lr) * pct) + initial_lr | |
if epoch > warmup_epochs and epoch < warmup_epochs+decay_epochs: | |
pct = 1 - ((epoch - warmup_epochs) / decay_epochs) | |
return ((base_lr - min_lr) * pct) + min_lr | |
return min_lr | |
callbacks += [keras.callbacks.LearningRateScheduler(partial(lr_scheduler, ...), verbose=0)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you provide a example to the code?