Aan de slagGa gratis aan de slag

Early stopping your model

The early stopping callback is useful since it allows for you to stop the model training if it no longer improves after a given number of epochs. To make use of this functionality you need to pass the callback inside a list to the model's callback parameter in the .fit() method.

The model you built to detect fake dollar bills is loaded for you to train, this time with early stopping. X_train, y_train, X_test and y_test are also available for your use.

Deze oefening maakt deel uit van de cursus

Introduction to Deep Learning with Keras

Cursus bekijken

Oefeninstructies

  • Import the EarlyStoppingcallback from tensorflow.keras.callbacks.
  • Define a callback, monitor 'val_accuracy' with a patience of 5 epochs.
  • Train your model using the early stopping callback.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import the early stopping callback
from tensorflow.____.____ import ____

# Define a callback to monitor val_accuracy
monitor_val_acc = ____(monitor=____, 
                       patience=____)

# Train your model using the early stopping callback
model.____(____, ____, 
           epochs=1000, validation_data=____,
           callbacks= ____)
Code bewerken en uitvoeren