How to Save and Load Your Keras Deep Learning Model

Last Updated on August 27, 2020

Keras is a simple and powerful Python library for deep learning.

Given that deep learning models can take hours, days and even weeks to train, it is important to know how to save and load them from disk.

In this post, you will discover how you can save your Keras models to file and load them up again to make predictions.

After reading this tutorial you will know:

  • How to save model weights and model architecture in separate files.
  • How to save model architecture in both YAML and JSON format.
  • How to save model weights and architecture into a single file for later use.

Kick-start your project with my new book Deep Learning With Python, including step-by-step tutorials and the Python source code files for all examples.

Let’s get started.

  • Update Mar 2017: Added instructions to install h5py first.
  • Update Mar/2017: Updated examples for changes to the Keras API.
  • Update Mar/2018: Added alternate link to download the dataset.
  • Update May/2019: Added section on saving and loading the model to a single file.
  • Update Sep/2019: Added note about using PyYAML version 5.
To finish reading, please visit source site