Created
June 7, 2018 16:04
-
-
Save alessiamarcolini/f5f8dfe1f29cc5a6052ad0f0109e4602 to your computer and use it in GitHub Desktop.
Cyclical Learning Rates - Keras
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
def clr(self): | |
cycle = np.floor(1 + self.clr_iterations / (2 * self.step_size)) | |
x = np.abs(self.clr_iterations / self.step_size - 2 * cycle + 1) | |
if self.scale_mode == 'cycle': | |
return self.base_lr + (self.max_lr - self.base_lr) * \ | |
np.maximum(0, (1 - x)) * self.scale_fn(cycle) | |
else: | |
return self.base_lr + (self.max_lr - self.base_lr) * \ | |
np.maximum(0, (1 - x)) * self.scale_fn(self.clr_iterations) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment