Bird
0
0

Given this code snippet for training with early stopping, what will be printed?

medium📝 Predict Output Q13 of 15
Agentic AI - Production Agent Architecture
Given this code snippet for training with early stopping, what will be printed?
from tensorflow.keras.callbacks import EarlyStopping
early_stopping = EarlyStopping(monitor='val_loss', patience=2)
history = model.fit(X_train, y_train, epochs=10, validation_split=0.2, callbacks=[early_stopping])
print(len(history.history['loss']))
ALess than 10
B10
CMore than 10
DError because EarlyStopping is not defined
Step-by-Step Solution
Solution:
  1. Step 1: Understand EarlyStopping behavior

    EarlyStopping stops training early if validation loss does not improve for 'patience' epochs, so training may stop before 10 epochs.
  2. Step 2: Predict length of loss history

    Since training can stop early, the number of loss entries will be less than 10.
  3. Final Answer:

    Less than 10 -> Option A
  4. Quick Check:

    EarlyStopping stops early, so epochs run < 10 [OK]
Quick Trick: EarlyStopping can reduce epochs, so history length is less than max [OK]
Common Mistakes:
  • Assuming training always runs full 10 epochs
  • Confusing patience with number of epochs
  • Thinking EarlyStopping causes errors if used correctly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes