我正在使用 tensorflow 后端在 Keras 中训练一个序列模型。我还包括了一些回调来保存检查点并在模型开始过度拟合时恢复到最佳权重(它会)。
我的问题 - 在使用这组回调进行拟合时,最终检查点是否包含具有最佳权重的模型版本?我知道权重classif_model会恢复,但我不确定这是否也适用于最终保存的状态。
from keras import callbacks as kc
classif_model = my_model(input_shape)
# Set up callbacks
checkpointer = kc.ModelCheckpoint(filepath='results/'+name+'.h5', verbose=0)
earlystopping = kc.EarlyStopping(monitor='val_loss', patience=patience, restore_best_weights = True)
callbacks = [checkpointer, earlystopping]
# train the model
hist = classif_model.fit(x = X_tr, y = Y_tr, epochs = epochs, batch_size = batch_size,
callbacks = callbacks, validation_data = (X_val, Y_val),
verbose = 0)