Load and Use a Saved Keras Model

Chris Achard
InstructorChris Achard
Share this video with your friends

Social Share Links

Send Tweet

We will load a saved model from a file, and then use it to make predictions on new data. We won’t need to know anything about the model to do this - we can do it all in a new file by loading a saved model.

Instructor: [00:01] In a new Python file, import load model from keras.models. Then we can call the load model function, passing the file name of the model file that we saved. The result of that will be the entire trained model, so we can assign that to the model variable.

[00:23] We can see the model details by calling model.summary. When we run that, we see all of the layers in the network and their sizes. This allows us to load and even inspect models that we didn't make ourselves. Then we can use this model to make predictions since it's a fully-trained model.

[00:43] First, import NumPy, and then make a few input arrays to make predictions on. Then use the model's predict method to actually make those predictions. When we run that, we see the model's output predictions.