更新时间:2023-12-01 22:02:28
history_model_1
是回调对象.它包含各种数据,并且不可序列化.
history_model_1
is a callback object. It contains all sorts of data and isn't serializable.
但是,它包含一个词典,其中包含您实际要保存的所有值(请参见您的注释):
However, it contains a dictionnary with all the values that you actually want to save (cf your comment) :
import json
# Get the dictionary containing each metric and the loss for each epoch
history_dict = history_model_1.history
# Save it under the form of a json file
json.dump(history_dict, open(your_history_path, 'w'))
您现在可以像这样在第50个时期访问损失值:
You can now access the value of the loss at the 50th epoch like this :
print(history_dict['loss'][49])
重新加载
history_dict = json.load(open(your_history_path, 'r'))
我希望这会有所帮助.