From the course: Deep Learning with Python and Keras: Build a Model for Sentiment Analysis

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Serializing a model to disk and loading model

Serializing a model to disk and loading model

- [Narrator] In this movie, we'll see how you can save your model out to the local disk, and then load your model from disk and use it for prediction. Now, if you want to export your model, you should include the vectorize_layer as a part of your model. This will allow you to feed in raw text inputs to your model and get predictions for that raw text. Your data need not be pre-processed before you feed that into the model. So here I've set up the export_model with the vectorize_layer and the lstm_model that is fed with the vectorized data. I call export_model.compile to configure the options for training the model if needed, the loss function, the optimizer, and the metrics to track. And let's call export_model.evaluate on the raw test data to make sure that the data is processed and we get the right accuracy. And you can see the accuracy here is about the same, about 64%. Let's now use this model to perform…

Contents