Skip to content Skip to sidebar Skip to footer

Keyerror: Failed To Format This Callback Filepath

I am trying to obtain the validation accuracy and the choose to save the model having the best accuracy.But after the 1st epoch,it is showing the checkpoint error. filepath='tumor_

Solution 1:

Replace both

'val_acc'

in file_path and checkpoint with

'val_accuracy'

and it will work.

Solution 2:

I added validation_split=0.1 and worked for me:

...
my_callbacks = [
    tf.keras.callbacks.EarlyStopping(patience=2),
    tf.keras.callbacks.ModelCheckpoint(filepath='model.{epoch:02d}-{val_loss:.2f}.h5'),
    tf.keras.callbacks.TensorBoard(log_dir='./logs'),
]

history = model.fit(X_train, y_train, validation_split=0.1, epochs=200, callbacks=my_callbacks)

Solution 3:

This is possibly a duplicate of this question.

I had the same problem when training with a smaller dataset, where the validation split for the training data was 0.

Solution 4:

replace this

val_accuracy

with this

val_acc

I Try this and it works

Post a Comment for "Keyerror: Failed To Format This Callback Filepath"