3

我正在训练 Keras 模型,保存它们,model.save()然后加载它们并恢复训练。

我想在每次训练后绘制整个训练历史,但model.fit_generator()只返回最后一次训练的历史。

我可以保存初始会话的历史并自己更新,但我想知道 Keras 中是否有管理训练历史的标准方法。

history1 = model.fit_generator(my_gen)
plot_history(history1)
model.save('my_model.h5')

# Some days afterwards...

model = load_model('my_model.h5')
history2 = model.fit_generator(my_gen)

# here I would like to reconstruct the full_training history
# including the info from history1 and history2
full_history = ???
4

2 回答 2

1

事实证明,在 Keras 中还没有标准的方法来执行此操作,但 AFAIK。

有关上下文,请参阅此问题

于 2018-10-31T14:37:56.167 回答
0

让我们说这条线

print(history.history.keys())

产生以下输出:

['acc', 'loss', 'val_acc', 'val_loss']

基于加载的模型应该与保存的模型具有相同性能的假设,您可以尝试连接历史记录。例如,在已加载模型的已加载精度历史记录上连接新的精度历史记录。

它应该从加载模型结束的绘图空间中的同一点开始(也许您必须为绘图添加先前训练模型的 (+) 时期,以便新的准确度值不会从时期 0 开始,但是加载模型的最后一个时期)。

我希望你能理解我的想法,它会帮助你:)

于 2018-10-31T11:48:41.053 回答