gpt4 book ai didi

python - Keras ModelCheckpoint 监控多个值

转载 作者:太空宇宙 更新时间:2023-11-03 14:04:53 25 4
gpt4 key购买 nike

我想使用 Keras ModelCheckpoint 回调来监视多个参数(我有一个多任务网络)。只需要一个回调就可以吗?或者我需要在许多回调中这样做吗??

创建 ckechpoint :

checkpointer = ModelCheckpoint(filepath='checkpoints/weights-{epoch:02d}.hdf5', monitor='val_O1_categorical_accuracy' , verbose=1, save_best_only=True, mode='max')

我要监控的第二个参数:val_O2_categorical_accuracy

在列表中这样做是行不通的。即

checkpointer = ModelCheckpoint(filepath='checkpoints/weights-{epoch:02d}.hdf5', monitor=['val_O1_categorical_accuracy','val_O2_categorical_accuracy'] , verbose=1, save_best_only=True, mode='max')

TypeError: unhashable type: 'list'

最佳答案

恐怕您必须在不同的情况下执行此操作。想想这里发生了什么 -

checkpointer = ModelCheckpoint(filepath='checkpoints/weights-{epoch:02d}.hdf5', monitor='val_O1_categorical_accuracy' , verbose=1, save_best_only=True, mode='max')

当您通过监视 val_O1_categorical_accuracy 来保存模型时,以下是它在伪代码中执行的操作 -

for each epoch:
check the val_O1_categorical_accuracy after updating weights
if this metric is better in this epoch than the previous ones:
save the model
else
pass

因此,真正指定多个监视器超出了范围。在这种情况下,它必须是一个非此即彼的选择,因为基于监控指标,在其他冲突模型中只有一个模型可能是最好的。

关于python - Keras ModelCheckpoint 监控多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48971221/

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