Created
August 22, 2019 21:39
-
-
Save karolzak/c3890b485343280cf19b9d4d118f7bcc to your computer and use it in GitHub Desktop.
Some callbacks for keras
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
| from keras.callbacks import ModelCheckpoint | |
| checkpoint_callback = ModelCheckpoint( | |
| "c3d_v5_chkpt-{epoch:02d}-{val_loss:.2f}-{val_acc:.2f}.hdf5", | |
| monitor='val_loss', | |
| verbose=1, | |
| save_best_only=True, | |
| save_weights_only=False, | |
| mode='auto', | |
| period=1) | |
| from keras.callbacks import LearningRateScheduler | |
| import math | |
| def step_decay(epoch): | |
| initial_lrate = 0.003 | |
| drop = 0.5 | |
| epochs_drop = 1 | |
| lrate = initial_lrate * math.pow(drop, math.floor((epoch)/epochs_drop)) | |
| return lrate | |
| lrate = LearningRateScheduler(step_decay, verbose=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment