0
0
TensorFlowml~10 mins

Early stopping in TensorFlow - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the EarlyStopping callback from TensorFlow.

TensorFlow
from tensorflow.keras.callbacks import [1]
Drag options to blanks, or click blank then click option'
ATensorBoard
BReduceLROnPlateau
CEarlyStopping
DModelCheckpoint
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong callback like ModelCheckpoint or TensorBoard.
Forgetting to import from keras.callbacks.
2fill in blank
medium

Complete the code to create an EarlyStopping callback that monitors validation loss.

TensorFlow
early_stop = EarlyStopping(monitor='[1]', patience=3)
Drag options to blanks, or click blank then click option'
Aval_loss
Baccuracy
Closs
Dval_accuracy
Attempts:
3 left
💡 Hint
Common Mistakes
Monitoring training loss instead of validation loss.
Using accuracy instead of loss for early stopping.
3fill in blank
hard

Fix the error in the code to correctly use EarlyStopping in model.fit.

TensorFlow
model.fit(X_train, y_train, epochs=50, callbacks=[[1]])
Drag options to blanks, or click blank then click option'
AEarlyStopping()
Bearly_stop()
CEarlyStopping
Dearly_stop
Attempts:
3 left
💡 Hint
Common Mistakes
Calling the callback instance with parentheses.
Passing the class name instead of the instance.
4fill in blank
hard

Fill both blanks to create EarlyStopping that stops if validation accuracy does not improve for 5 epochs and restores best weights.

TensorFlow
early_stop = EarlyStopping(monitor='[1]', patience=[2], restore_best_weights=True)
Drag options to blanks, or click blank then click option'
Aval_accuracy
Bval_loss
C3
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using validation loss instead of accuracy.
Setting patience too low or forgetting restore_best_weights.
5fill in blank
hard

Fill all three blanks to create EarlyStopping monitoring validation loss with patience 4 and verbose output.

TensorFlow
early_stop = EarlyStopping(monitor='[1]', patience=[2], verbose=[3])
Drag options to blanks, or click blank then click option'
Aval_accuracy
Bval_loss
C4
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using verbose=0 which hides messages.
Monitoring training loss instead of validation loss.