Skip to content

Instantly share code, notes, and snippets.

@mirrornerror
Last active October 27, 2018 10:43
Show Gist options
  • Save mirrornerror/b41848739ddf03e405578afb0e72424b to your computer and use it in GitHub Desktop.
Save mirrornerror/b41848739ddf03e405578afb0e72424b to your computer and use it in GitHub Desktop.
from keras.callbacks import EarlyStopping, ModelCheckpoint, ReduceLROnPlateau
reduce_lr = ReduceLROnPlateau(monitor='val_loss', factor=0.2, patience=3, min_lr=0.000001,verbose=1)
checkpointer = ModelCheckpoint(filepath='checkpoint.hdf5', verbose=1, save_best_only=True)
early_stopping = EarlyStopping(patience=10, verbose=1)
history = model.fit(x_train, y_train,
epochs=300,
batch_size=32,
verbose=1,
validation_split=0.1,
callbacks=[reduce_lr, early_stopping, checkpointer])
model.load_weights('checkpoint.hdf5')
pred = model.predict(x_test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment