Saving and reloading a model

We know that each time we run a model in Keras, the model starts with different starting points due to random initial weights. Once we arrive at a model with an acceptable level of performance and would like to reuse the same model in the future, we can save the model using the save_model_hdf5 function. We can then load this same model using the load_model_hdf5 function:

# Save and reload model
save_model_hdf5(model,
filepath,
overwrite = TRUE,
include_optimizer = TRUE)
model_x <- load_model_hdf5(filepath,
custom_objects = NULL,
compile = TRUE)

The preceding code will allow us to save the model architecture and the model weights, and, if needed, will allow us to resume the training of the model from the previous training session. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset