In Keras, saving and restoring models is very simple. Keras provides three options:
- Save the complete model with its network architecture, weights (parameters), training configuration, and optimizer state.
- Save only the architecture.
- Save only the weights.
For saving the complete model, use the model.save(filepath) function. This will save the complete model in an HDF5 file. The saved model can be loaded back using the keras.models.load_model(filepath) function. This function loads everything back, and then also compiles the model.
For saving the architecture of a model, use either the model.to_json() or model.to_yaml() function. These functions return a string that can be written to the disk file. While restoring the architecture, the string can be read back and the model architecture restored using the keras.models.model_from_json(json_string...