Currently, this is the code I have. I know the problem is in the checkpoint callback because I've tested running my program without it and it works fine.
model.compile(optimizer = 'adam', loss = 'categorical_crossentropy', metrics = ['accuracy'])
class_weight = {0: 70.,
1: 110.,
2: 82.,
3: 17.,
4: 33.,
5: 1.,
6: 1.,
7: 9.}
lr_schedule = tf.keras.callbacks.LearningRateScheduler(lr_schedule)
checkpoint = tf.keras.callbacks.ModelCheckpoint(filepath='Checkpoint/model.{epoch:02d}-{val_loss:.4f}.h5',
save_weights_only=True,
save_best_only=True,monitor='loss',
mode='min',verbose=1)
model.fit(train_generator, epochs = 5, steps_per_epoch=10, callbacks=[lr_schedule, checkpoint], class_weight=(class_weight))
In a folder named tests I have the pyton file and another folder called Checkpoint. I want to save my model inside the folder named Checkpoint but I've tried different name and all give me the error below
Error:
'Failed to format this callback filepath: "Checkpoint/model.{epoch:02d}-{val_loss:.4f}.h5". Reason: \'val_loss\'
How can I make the ModelCheckpoint work correctly?
EDIT: I am not using validation data because my monitor is based on the loss function. I have updated my version of tensorflow by doing activate <name_of_env>
followed by pip install tensorflow --upgrade
. After this I ran it again and I still get the same error.
I was wondering, do I have to have something inside the Checkpoint folder for it to work?