gpt4 book ai didi

tensorflow - TF/喀拉斯 : ModelCheckpoint "period" and "save_best_only"

转载 作者:行者123 更新时间:2023-12-05 01:35:19 25 4
gpt4 key购买 nike

如果我使用 Keras 回调 ModelCheckpoint,并设置 save_best_only = Trueperiod=3,将如何保存模型? 3 个周期后,它会保存这 3 个周期的最佳结果,还是只保存所有周期中最好的一个?
我使用的一段代码:

mcp = tf.keras.callbacks.ModelCheckpoint("my_model.h5", monitor="val_accuracy",
save_best_only=True, period=3)

最佳答案

首先根据documentation , period 参数已弃用,取而代之的是 save_freq 参数(如果将其分配给 int,它将考虑已见批处理的数量而不是纪元).但为了向后兼容,period 参数仍然有效。

但要找到您问题的答案,我们需要检查 ModelCheckpoint 回调的源代码。实际上,到目前为止看到的监控指标的最佳值is updated只有 if period epochs has passed (自上次检查点以来)。并且。自迄今为止看到的最佳指标值is compared仅使用当前时期的监控指标值,因此我们可以得出结论,只有时期中表现最好的模型 period, 2*period, 3*period 等进行比较并保存,并且忽略这些 epoch 之间的模型性能

关于tensorflow - TF/喀拉斯 : ModelCheckpoint "period" and "save_best_only",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63013929/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com