how to save and load model in keras 1

how to save and load model in keras

# To save the model:

from keras.models import save_model

# you can write whatever you desire instead of 'my_model'
# model = Your trained model
model.save('my_model')

# To load the model:

from keras.models import load_model

reconstructed_model = load_model("my_model")

Here is what the above code is Doing:
1. It saves the model’s architecture in a .json file.
2. It saves the model’s weights in a .h5 file.
3. It saves the model’s training configuration in a .yaml file.
4. It saves the optimizer’s configuration in a .yaml file.

Similar Posts