0

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

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)
4

1 回答 1

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']
于 2019-01-05T11:36:50.363 回答