PIXELBANKv8.2.1
Menu

Early Stopping Check

Problem Statement

Determine if training should stop based on validation loss history.

Background

Early stopping is a regularization technique that stops training when the model stops improving on a validation set. This prevents overfitting to the training data.

The rule: stop if validation loss hasn't improved for patience consecutive epochs.

Your Task

Write a function should_stop(history_losses, patience) that returns True if training should stop.

Output Format

Return a boolean: True if should stop, False otherwise.

Example:

Input:
history_losses=[5.0, 4.0, 4.1, 4.2], patience=2
Output:
True
Reasoning:

Best loss was 4.0 at index 1. Current index is 3. Epochs since best: 3-1=2. Since 2 >= patience(2), return True.

Constraints:

  • len(history_losses) >= 1
  • patience >= 1
  • All losses are positive numbers
Editor

Test Results

0/0
Run code to see test results.