Keras:多次训练10个epoch,是否需要重新加载模型?

Keras: Is there a need to reload the model if I train for 10 epochs multiple times?

我正在训练模型并想使用 mAP 指标。出于某种原因,tensorflow mean_average_precision_at_k 对我不起作用,但 sklearn average_precision_score 有效。 我怎样才能访问 keras 的模型输出来执行 sklearn 指标? 我可以编译模型一次并适合 10 个时期,执行度量并再次适合 10 个时期吗?或者我是否需要保存模型并每​​次都重新加载? 谢谢

Can I compile the model one time and fit for 10 epochs, perform the metric and fit again for 10 epochs

是的,绝对。

模型将在 fit() 调用之间保持训练权重。您可以多次调用它。

对于可能遇到相同问题的任何人。似乎在 Tensorflow 1.14 中,Keras 的实现保留了模型权重,但重新启动了优化器,这导致多次重复 .fit() 函数时出现不良结果。使用 .fit() 一次时我的损失约为 800,每次拟合 5 个时期时损失约为 2800。