Last active
November 27, 2018 08:55
-
-
Save notha99y/2a77c36f698ad0e94ee691f1fcef0187 to your computer and use it in GitHub Desktop.
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
# Importing the Callbacks | |
from keras.callbacks import EarlyStopping | |
from keras.callbacks import TensorBoard | |
from keras.callbacks import ModelCheckpoint | |
# Saving logs | |
LOG_DIR = os.path.join(os.getcwd(), 'logs') | |
tb = TensorBoard(LOG_DIR) | |
# Saving weights | |
weights_dir = 'weights/' + model.name + \ | |
'-{epoch:02d}-{loss:.2f}.hdf5' | |
chkpt = ModelCheckpoint(filepath=weights_dir, monitor='loss', save_best_only=True, save_weights_only=True, mode='auto', period=1) | |
# Stop training when val_acc is not improving after 5 epochs | |
early_stop = EarlyStopping(monitor='val_acc', min_delta=0, patience=5) | |
history = model.fit(X_train, Y_train, epochs=50, batch_size=3, validation_data = (X_test, Y_test), callbacks=[tb, chkpt, early_stop]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment