如何继续保存Keras中验证丢失的历史记录

时间:2019-01-05 00:14:30

标签: keras history

让我说我想以100个纪元训练。但是在50个时期之后,我想每5个时期保存一次模型。我也想保存历史。我不确定该怎么做,所以我做了下面的事情。请让我知道如何继续保存历史记录。

history = model.fit(X_train, y_train, validation_split = 0.2, shuffle=True, batch_size=gb.BATCH_SIZE, epochs=50)

counters = gb.EPOCHS_COUNT  // 5

for counter in range(counters):
    history += model.fit(X_train, y_train, validation_split = 0.2, shuffle=True, batch_size=gb.BATCH_SIZE, epochs=5)
    modelName = "model_weights_total_0"+str(counter)+".h5"
    model.save(model_save_path+modelName, overwrite=True)

1 个答案:

答案 0 :(得分:0)

一种方法是手动求和history.history个值。

val_losses = []
for counter in range(counters):
    history = model.fit(X_train, y_train, validation_split = 0.2, shuffle=True, batch_size=gb.BATCH_SIZE, epochs=5)
    val_losses += history.history['val_loss']