A combination of callbacks
Deep learning models can take a long time to train, especially when you move to deeper architectures and bigger datasets. Saving your model every time it improves as well as stopping it when it no longer does allows you to worry less about choosing the number of epochs to train for. You can also restore a saved model anytime and resume training where you left it.
The model training and validation data are available in your workspace as X_train, X_test, y_train, and y_test.
Use the EarlyStopping() and the ModelCheckpoint() callbacks so that you can go eat a jar of cookies while you leave your computer to work!
Diese Übung ist Teil des Kurses
Introduction to Deep Learning with Keras
Anleitung zur Übung
- Import both the 
EarlyStoppingandModelCheckpointcallbacks fromtensorflow.keras. - Create 
monitor_val_accas anEarlyStoppingcallback that will monitor'val_accuracy', with apatienceof 3 epochs. - Create 
model_checkpointas aModelCheckpointcallback, save the best model asbest_banknote_model.hdf5. - Fit your model providing a list with the defined callbacks and 
X_testandy_testas validation data. 
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Import the EarlyStopping and ModelCheckpoint callbacks
from tensorflow.____.____ import ____, ____
# Early stop on validation accuracy
monitor_val_acc = ____(monitor = ____, patience = ____)
# Save the best model as best_banknote_model.hdf5
model_checkpoint = ____(____, save_best_only = True)
# Fit your model for a stupid amount of epochs
h_callback = model.fit(X_train, y_train,
                    epochs = 1000000000000,
                    callbacks = [____, ____],
                    validation_data = (____, ____))