若有進步就儲存,且保留上次最好的。
filepath="weights-improvement-{epoch:02d}-{val_acc:.2f}.hdf5"
checkpoint = ModelCheckpoint(filepath, monitor='val_acc', verbose=1, save_best_only=True, mode='max')
若有進步就儲存,但只保留最好的。
filepath="weights.best.hdf5"
checkpoint = ModelCheckpoint(filepath, monitor='val_acc', verbose=1, save_best_only=True, mode='max')
讀取尚未訓練完成的Model,但需要Initialize一開始模型的樣子。
model.load_weights("weights.best.hdf5")
參考: 1.How to Check-Point Deep Learning Models in Keras 2.Usage of callbacks