Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Load and Use a Saved Keras Model


    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.



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    Instructor: 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.

    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.

    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.