def constant(t, eta=3e-3):
return eta
def cosine(t, eta=3e-3, T=2000):
return eta * (1 + math.cos(math.pi * t / T)) / 2
def stable_decay(t, eta=3e-3, decay_start=1600, T=2000):
"""eta until decay_start, then a linear decay to zero at step T."""
return eta * min(1, (T - t) / (T - decay_start))
def warmup(schedule, num_steps):
"""schedule, ramped up linearly over its first num_steps steps."""
return lambda t: min(1, (t + 1) / num_steps) * schedule(t)