Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# 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/' + + \
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 =, 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
You can’t perform that action at this time.