I saw two ways of saving the weights of a keras model.
First way;
checkpointer = ModelCheckpoint(filepath=\"weights.hdf5\", verbose=1, save_best_only=Tru
No, there is no difference performance-wise. These are just two different ways of how and especially when the model shall be saved. Using model.save_weights
requires to especially call this function whenever you want to save the model, e.g. after the training or parts of the training are done. Using ModelCheckpoint
is much more convenient if you are still developing a model. Using this way, keras
can save a checkpoint of your model after each training epoch, so that you can restore the different models; or you can set save_best_only=True
so that keras
will overwrite the latest checkpoint only if the performance has improved, so that you end with the best performing model.
To summarize it: these are just two different ways of doing two different things. It depends on your use case and needs, what's the best.
As fundamentally explained here reference.wolfram.com/language/ref/format/HDF5.html
HDF
is an acronym for Hierarchical Data Format.HDF5
is HDF Version 5.
Import["file.h5"]
imports an HDF5 file, returning the names of the datasets stored in the file.
In Keras documents; as you can see here keras.io/api/models/model_saving_apis/
model.save('my_model.h5') # creates a HDF5 file 'my_model.h5'
In Tensorflow documents; as you can see here tensorflow.org/tutorials/keras/save_and_load
# Save the entire model to a HDF5 file.
# The '.h5' extension indicates that the model should be saved to HDF5.
model.save('my_model.h5')
At fundamental level they are same thing. They cant create any difference.