def train_sequential(model, X, y, where_to_save, fit_params=None, monitor='val_acc'):
# TODO: DOCUMENT once thoroughly tested
# Watch out: where_to_save might be inside fit_params
if fit_params is None:
fit_params = {
"batch_size": 32,
"nb_epoch": 45,
"verbose": True,
"validation_split": 0.15,
"show_accuracy": True,
"callbacks": [EarlyStopping(verbose=True, patience=5, monitor=monitor),
ModelCheckpoint(where_to_save, monitor=monitor, verbose=True, save_best_only=True)]
}
print 'Fitting! Hit CTRL-C to stop early...'
history = "Nothing to show"
try:
history = model.fit(X, y, **fit_params)
except KeyboardInterrupt:
print "Training stopped early!"
history = model.history
return history
评论列表
文章目录