Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the metrics issue in a nested trainer #20197

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

james77777778
Copy link
Contributor

Fix #20188

The root cause is that we might have unbuilt (and unusable) metrics with a nested trainer.
The solution is to clear these metircs and skip them when calling self.metrics in the newly instantiated trainer.

@codecov-commenter
Copy link

codecov-commenter commented Sep 2, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 10 lines in your changes missing coverage. Please review.

Project coverage is 79.36%. Comparing base (8b1ca95) to head (a115d4d).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
keras/src/trainers/trainer.py 71.42% 4 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #20197      +/-   ##
==========================================
- Coverage   79.37%   79.36%   -0.01%     
==========================================
  Files         501      501              
  Lines       47350    47379      +29     
  Branches     8695     8706      +11     
==========================================
+ Hits        37582    37601      +19     
- Misses       8011     8015       +4     
- Partials     1757     1763       +6     
Flag Coverage Δ
keras 79.21% <71.42%> (-0.01%) ⬇️
keras-jax 62.49% <71.42%> (+<0.01%) ⬆️
keras-numpy 57.65% <45.71%> (-0.02%) ⬇️
keras-tensorflow 63.88% <71.42%> (+<0.01%) ⬆️
keras-torch 62.54% <71.42%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@fchollet fchollet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Sep 2, 2024
@fchollet fchollet merged commit 18ee0a6 into keras-team:master Sep 2, 2024
7 checks passed
@google-ml-butler google-ml-butler bot removed ready to pull Ready to be merged into the codebase kokoro:force-run labels Sep 2, 2024
@james77777778 james77777778 deleted the fix-trainer-metrics branch September 3, 2024 00:37
@mattdangerw
Copy link
Member

@james77777778 looks like this broke KerasNLP on nightly.

https://github.com/keras-team/keras-nlp/actions/runs/10687238938/job/29624381773

Do we need to check with hasattr or getattr somewhere in here? Or is KerasNLP doing something wrong?

@james77777778
Copy link
Contributor Author

I just noticed this. Will try to fix it ASAP.

Using hasattr might be the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Assigned Reviewer
Development

Successfully merging this pull request may close these issues.

Cannot get result() since the metric has not yet been built
5 participants