print the epoch number in which it saved

21 Views Asked by At

i saved the weights of model in filepath and now when I load the weights I see something this:

<tensorflow.python.checkpoint.checkpoint.CheckpointLoadStatus object at 0x7b3e7e6e5000>

and I dont know in which epoch the model was saved because I want to continue to train the model from that epoch I dont know what epoch it is.can somebody help me to understand the epoch that model was saved?

#save the weights
checkpoint_filepath = '/content/pamap2-fedavg-128'
checkpoint_callback = tf.keras.callbacks.ModelCheckpoint(
filepath=checkpoint_filepath,
save_weights_only=True,
monitor='acc',  
mode='auto',
save_best_only=False,
verbose=1,
)
#load the weights
checkpoint_filepath = '/content/pamap2-fedavg-128'
print (global_model.load_weights(checkpoint_filepath)
1

There are 1 best solutions below

0
user2586955 On

So according to the documentation of ModelCheckPoint you can pass the epoch number format by '{epoch:02}'. For example:

checkpoint_callback = tf.keras.callbacks.ModelCheckpoint(
filepath='/content/pamap2-fedavg-128_{epoch_02d}.h5',
save_weights_only=True,
monitor='acc',  
mode='auto',
save_best_only=False,
verbose=1,
)