Skip to content

Instantly share code, notes, and snippets.

@maskaravivek
Created June 22, 2020 06:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maskaravivek/bbb1fcf51f2ba464585f5ac2d0f5793c to your computer and use it in GitHub Desktop.
Save maskaravivek/bbb1fcf51f2ba464585f5ac2d0f5793c to your computer and use it in GitHub Desktop.
LR_SCHEDULE = [
# (epoch to start, learning rate) tuples
(0, 0.01),
(75, 0.001),
(105, 0.0001),
]
def lr_schedule(epoch, lr):
"""Helper function to retrieve the scheduled learning rate based on epoch."""
if epoch < LR_SCHEDULE[0][0] or epoch > LR_SCHEDULE[-1][0]:
return lr
for i in range(len(LR_SCHEDULE)):
if epoch == LR_SCHEDULE[i][0]:
return LR_SCHEDULE[i][1]
return lr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment