Project Creation: Part Three
Explore how to implement Keras callbacks such as ModelCheckpoint and EarlyStopping to optimize training of an RNN for IMDB reviews sentiment analysis. Understand how these callbacks help save the best model and stop training early to avoid overfitting, visualize training and validation metrics, and evaluate model performance.
In the previous lesson, our model architecture was read. Now, before moving to actual training, I want to first introduce you to something new.
Callbacks in Keras
Many times when we are training our model, we see that the training accuracy starts decreasing after a certain number of epochs and our model ends up with low accuracy (although we achieved high accuracy in previous epochs). So, how can we get the best model out of all the epochs? The answer is callbacks.
A callback is an object that can perform actions at various stages of training, e.g., at the start or end of an epoch, before or after a single batch, etc.
We will discuss two types of callbacks and use them in our project.
1. ModelCheckpoint
The ModelCheckpoint callback is used in conjunction with training to save a model or weights (in a checkpoint file) at some interval, so the model or weights can be loaded later to continue the training from ...