Difference between Keras model.save() and model.save_weights()?
Just to add what ModelCheckPoint's output is, if it's relevant for anyone else: used as a callback during model training, it can either save the whole model or just the weights depending on what state the save_weights_only
argument is set to. TRUE and weights only are saved, akin to calling model.save_weights()
. FALSE (default) and the whole model is saved, as in calling model.save()
.
model.save_weights()
: Will only save the weights so if you need, you are able to apply them on a different architecturemode.save()
: Will save the architecture of the model + the the weights + the training configuration + the state of the optimizer
save()
saves the weights and the model structure to a single HDF5
file. I believe it also includes things like the optimizer state. Then you can use that HDF5 file with load()
to reconstruct the whole model, including weights.
save_weights()
only saves the weights to HDF5 and nothing else. You need extra code to reconstruct the model from a JSON
file.