在训练带有图像的数据集时出现KeyError:'val_acc'

时间:2020-02-22 17:31:53

标签: python keras image-recognition

我正在尝试使用以下代码训练带有图像的数据集,但是我得到了:

KeyError:'val_acc'

#Directory in which to create models
save_direc = os.path.join(os.getcwd(), 'idenprof_models')

# Name of model files
model_name = 'idenprof_weight_model.{epoch:03d}-{val_acc}.h5'

# Create Directory if it doesn't exist
if not os.path.isdir(save_direc):
    os.makedirs(save_direc)
# Join the directory with the model file
modelpath = os.path.join(save_direc, model_name)

# Checkpoint to save best model
checkpoint = ModelCheckpoint(filepath=modelpath,
                             monitor='val_acc',
                             verbose=1,
                             save_best_only=True,
                             save_weights_only=True,
                             period=1)

1 个答案:

答案 0 :(得分:0)

从val_acc更改为val_accuracy

# Name of model files
model_name = 'idenprof_weight_model.{epoch:03d}-{val_accuracy}.h5'


# Checkpoint to save best model
checkpoint = ModelCheckpoint(filepath=modelpath,
                             monitor='val_accuracy',
                             verbose=1,
                             save_best_only=True,
                             save_weights_only=True,
                             period=1)