Continue to Train an Already Trained Keras Model with New Data

Chris Achard
InstructorChris Achard
Share this video with your friends

Social Share Links

Send Tweet

As we get new data, we will want to re-train our old models with that new data. We’ll look at how to load the existing model, and train it with new data, and then save the newly trained model.

Instructor: [00:01] We can load an existing model by importing Load Model from Keras.Models, and then call Load Model and pass the file name of our saved model. We can look at the summary of that model to better understand what we just loaded.

[00:18] We can also continue training the saved model if we want to. We don't have the model defined in this file at all, but the saved file contains all the information that we need to pick up training right where we left off. We can import Numpy and use that to load the IRIS CSV file.

[00:41] We need to remember to switch the y-values from just a number to a one-hot encoded vector. First, import two-categorical and then we can use that on the y-values.

[01:01] We need to make sure to shuffle the data again since we're going to be using the validation split method. Finally, we can call fit just like normal.

[01:15] The model will pick up just where it left off and continue to train the network. This can be especially helpful if you get new data and you want to train an old model, or if you simply want to pause training because it's taking a long time and resume at a later time.