Add min_delta_mode parameter to EarlyStopping and update logic for sc…#3516
Merged
vfdev-5 merged 4 commits intopytorch:masterfrom Feb 6, 2026
Merged
Conversation
Collaborator
Author
|
The pytest and tests look very scary. Anyways, I could also refactor type annotations for these file in this pr if its fine. |
5fdeea1 to
25a5390
Compare
…ode in EarlyStopping
9d3058f to
ce70f0a
Compare
vfdev-5
reviewed
Feb 6, 2026
vfdev-5
reviewed
Feb 6, 2026
vfdev-5
reviewed
Feb 6, 2026
…arify absolute and relative increase thresholds
github-merge-queue bot
pushed a commit
that referenced
this pull request
Feb 6, 2026
#3516) This pull request enhances the `EarlyStopping` handler in `ignite/handlers/early_stopping.py` by introducing a new parameter to control how `min_delta` is interpreted, allowing users to specify whether the minimum improvement threshold should be considered as an absolute or relative increase. This makes early stopping more flexible and suitable for a wider range of training scenarios. **Early stopping configuration improvements:** * Added a new `min_delta_mode` parameter (with options `"abs"` or `"rel"`) to the `EarlyStopping` class, allowing users to specify whether `min_delta` is treated as an absolute or relative improvement. Default is `"rel"`. [[1]](diffhunk://#diff-90b35f252a4f1589bd64e544cc0fa83f556b0ae987d0f625cf66aa74df7ffcbfR23-R24) [[2]](diffhunk://#diff-90b35f252a4f1589bd64e544cc0fa83f556b0ae987d0f625cf66aa74df7ffcbfR54) * Updated the constructor to validate the `min_delta_mode` argument and store it as an instance attribute. [[1]](diffhunk://#diff-90b35f252a4f1589bd64e544cc0fa83f556b0ae987d0f625cf66aa74df7ffcbfR68-R70) [[2]](diffhunk://#diff-90b35f252a4f1589bd64e544cc0fa83f556b0ae987d0f625cf66aa74df7ffcbfR79-R90) * Modified the early stopping logic in `__call__` to compute the improvement threshold based on the selected `min_delta_mode`. **Type annotation updates:** * Updated type annotations to import `Literal` from `typing` for the new parameter. Part of issue #3411
vfdev-5
reviewed
Feb 6, 2026
| i.e. an increase of less than or equal to the minimum delta threshold (as determined by min_delta and min_delta_mode), will count as no improvement. | ||
| cumulative_delta: It True, `min_delta` defines an increase since the last `patience` reset, otherwise, | ||
| it defines an increase after the last event. Default value is False. | ||
| min_delta_mode: Determine whether `min_delta` is an absolute increase or a relative increase. |
Collaborator
There was a problem hiding this comment.
@aaishwarymishra I forgot, we should update the docstring with .. versionchanged:: directlve for the new arg. For example:
ignite/ignite/metrics/metric.py
Lines 281 to 282 in d2020e4
Collaborator
Author
There was a problem hiding this comment.
I can add all the changes in docs together in next pr if it sounds good?
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request enhances the
EarlyStoppinghandler inignite/handlers/early_stopping.pyby introducing a new parameter to control howmin_deltais interpreted, allowing users to specify whether the minimum improvement threshold should be considered as an absolute or relative increase. This makes early stopping more flexible and suitable for a wider range of training scenarios.Early stopping configuration improvements:
min_delta_modeparameter (with options"abs"or"rel") to theEarlyStoppingclass, allowing users to specify whethermin_deltais treated as an absolute or relative improvement. Default is"rel". [1] [2]min_delta_modeargument and store it as an instance attribute. [1] [2]__call__to compute the improvement threshold based on the selectedmin_delta_mode.Type annotation updates:
Literalfromtypingfor the new parameter.Part of issue #3411