Keras save checkpoints

Viewed 2893

I am following this blog and I am having trouble to implement saving checkpoints as it's used in linked blog. At line 23 it used:

filepath="weights-improvement-{epoch:02d}-{val_acc:.2f}.hdf5".

So I tried to tweak the code a little bit to be more dynamic:

filepath = '{0}/checkpoints/checkpoint-{epoch:02d}-{val_loss:.2f}.hdf5'.format(directory).

Where I want to store all checkpoints of given architecture in 1 directory, e.g.: ./architecture1/checkpoints/

But I get the following error: KeyError: 'epoch'. What am I doing wrong here?

P.S.: filepath = "./checkpoints/checkpoint-{epoch:02d}-{val_loss:.2f}.hdf5" works, but it saves all checkpoints in 1 directory which I don't want.

2 Answers
Related