Created
November 14, 2024 19:36
-
-
Save jakelevi1996/898b48bb5fadb47ece1ff6a4e4477528 to your computer and use it in GitHub Desktop.
Compare linear and cosine learning rate schedules
This file contains 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
import numpy as np | |
from jutility import plotting, util, cli, units | |
t_max = 300 | |
t_max = 100 | |
lr0 = 1e-3 | |
lr1 = 1e-5 | |
lr1 = 0 | |
t = np.arange(t_max) | |
x1 = lr1 + 0.5 * (lr0 - lr1) * (1 + np.cos(np.pi * t / t_max)) | |
x2 = np.linspace(lr0, lr1, t_max, endpoint=False) | |
plotting.MultiPlot( | |
plotting.Subplot( | |
plotting.Line(t, x1), | |
plotting.Line(t, x2, c="r"), | |
), | |
plotting.Subplot( | |
plotting.Line(t, x1), | |
plotting.Line(t, x2, c="r"), | |
log_y=True, | |
), | |
).save() |
Author
jakelevi1996
commented
Nov 14, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment