keras:如何保存历史对象的训练历史属性 [英] keras: how to save the training history attribute of the history object
本文介绍了keras:如何保存历史对象的训练历史属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Keras中,我们可以将model.fit
的输出返回到历史记录,如下所示:
In Keras, we can return the output of model.fit
to a history as follows:
history = model.fit(X_train, y_train,
batch_size=batch_size,
nb_epoch=nb_epoch,
validation_data=(X_test, y_test))
现在,如何将历史记录对象的历史记录属性保存到文件中以供进一步使用(例如,绘制历时的acc或损失图)?
Now, how to save the history attribute of the history object to a file for further uses (e.g. draw plots of acc or loss against epochs)?
推荐答案
我使用的是以下内容:
with open('/trainHistoryDict', 'wb') as file_pi:
pickle.dump(history.history, file_pi)
以这种方式,我将历史记录另存为字典,以备日后绘制损失或准确性时使用.
In this way I save the history as a dictionary in case I want to plot the loss or accuracy later on.
这篇关于keras:如何保存历史对象的训练历史属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文