关于回调函数callback中model_checkpoint的路径问题:“Failed to format this callback filepath:···”

使用回调函数的model_checkpoint时路径问题:

使用回调函数的model_checkpoint时,如下定义:

trained_models_path = "./trained_models/LeNet_5"
model_names = trained_models_path + '.{epoch:02d}-{acc:2f}.hdf5'
model_checkpoint = ModelCheckpoint(model_names,
                                   monitor='loss',
                                   verbose=1,
                                   save_best_only=True,
                                   save_weights_only=False)

会报故障:

KeyError: 'Failed to format this callback filepath: "./trained_models/LeNet_5.{epoch:02d}-{acc:2f}.hdf5". Reason: \'acc\''

查看报故障的文件位置,将缩写补全,即将acc改为accuracy。

你可能感兴趣的:(python,卷积神经网络,深度学习)