簡體   English   中英

Keras:如何在每個 epoch 之后存儲歷史?

[英]Keras: How to store history after each epoch?

我想在每個時代之后改變我的輸入,最后我想繪制學習曲線。

要更改輸入,我可以使用如下功能

for _ in range(num_epochs):
    x, y = generate_data()
    history = model.fit(x, y, epochs=1, batch_size=64)

但是我無法為我的模型捕獲完整的歷史記錄。 如何訪問它並繪制學習曲線?

您可以使用字典來存儲history

history_dict = dict()

for i in range(num_epochs):
    x, y = generate_data()
    history_dict['epoch_%i' % i] = model.fit(x, y, epochs=1, batch_size=64)

它會給出類似的東西:

Out[4]: 
{'epoch_0': <your history 1>,
 'epoch_1': <your history 2>,
 'epoch_2': <your history 3>,

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM