Skip to content

Conversation

SamBSalgado
Copy link
Contributor

Description

This PR fixes issue #3722 by extending the EarlyStoppingListener to support "trainLoss" as a valid monitored metric in addition to the default "validateLoss".

Previously, if a user specified "trainLoss" via .optMonitoredMetric("trainLoss"), the early stopping logic would not behave as expected because TrainingResult.getTrainLoss() was not considered in the metric selection. This update introduces an explicit check for "trainLoss" in the getMetric(...) method, ensuring it is properly used for early stopping decisions.

Changes Summary

  • The getMetric(...) method now explicitly supports "trainLoss" in addition to "validateLoss".

Result

  • When using .optMonitoredMetric("trainLoss"), training is now stopped early if the training loss fails to improve as specified.
  • This improves flexibility for users who want to monitor training loss instead of validation loss.

Closes #3722

@SamBSalgado SamBSalgado requested review from zachgk and a team as code owners July 18, 2025 01:11
@frankfliu
Copy link
Contributor

Please fix java format issue:

./gradlew fJ

@SamBSalgado
Copy link
Contributor Author

@frankfliu Done 👍🏻

@xyang16 xyang16 merged commit cb3469a into deepjavalibrary:master Aug 1, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EarlyStoppingListener don't work.
3 participants