In tensorflow’s documentation, the description of
save_weights_only parameter of ModelCheckpoint is as follows:
if True, then only the model’s weights will be saved (model.save_weights(filepath)), else the full model is saved (model.save(filepath)).
What does it mean by "the full model is saved"? I know that we use
save_weights_only=True. But what’s different when it’s False? I.e. what additional information is saved besides the weights? And how can we load this "full model"? Do we still need to define its layers and compile it before loading the saved model?
If you check the source code for
ModelCheckpoint you can see that when
save_weights_only=True you are actually calling
model.save_weights() where model is an instance of
tf.keras.Model. Checking the docs for the difference between
model.save, we are pointed to keras’ serialization and saving guide. Here it explains that whole model saving and loading entails:
- The model’s architecture/config.
- The model’s weight values.
- The model’s compilation information.
- The optimizer and its state, if any.
Answered By – o-90