keras--earlyStopping获取最佳模型
best_weights_filepath = './best_weights.hdf5'
earlyStopping=kcallbacks.EarlyStopping(monitor='val_loss', patience=10, verbose=1, mode='auto')
saveBestModel = kcallbacks.ModelCheckpoint(best_weights_filepath, monitor='val_loss', verbose=1, save_best_only=True, mode='auto')
# train model
history = model.fit(x_tr, y_tr, batch_size=batch_size, nb_epoch=n_epochs,
verbose=1, validation_data=(x_va, y_va), callbacks=[earlyStopping, saveBestModel])
#reload best weights
model.load_weights(best_weights_filepath)