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

Remove epoch from trainer.logged_metrics #9904

Merged
merged 3 commits into from
Oct 13, 2021
Merged

Remove epoch from trainer.logged_metrics #9904

merged 3 commits into from
Oct 13, 2021

Conversation

rohitgr7
Copy link
Contributor

What does this PR do?

Fixes #9825

Reason why I think epoch is not required here:

  1. If it's not logged explicitly by user then it shouldn't be inside logged_metrics since it's not something that is aggregated or computed.
  2. It won't be correct all the time since it's only updated when metrics are actually logged. For eg if someone is referring epoch from here in any of their *_step hooks then it won't be correct. We already have trainer.current_epoch for that.
  3. We don't have any other metrics that is used as a step label. For eg if someone do self.log('step', some_step) then we don't keep step inside logged_metrics.

But as always open to discussion/suggestions.

Does your PR introduce any breaking changes? If yes, please list them.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

@rohitgr7 rohitgr7 added this to the v1.5 milestone Oct 12, 2021
@rohitgr7 rohitgr7 added the logging Related to the `LoggerConnector` and `log()` label Oct 12, 2021
@rohitgr7 rohitgr7 marked this pull request as ready for review October 12, 2021 10:24
CHANGELOG.md Outdated Show resolved Hide resolved
@rohitgr7 rohitgr7 changed the title Remove epoch from logged_metrics Remove epoch from trainer.logged_metrics Oct 12, 2021
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

LGMT !

@codecov
Copy link

codecov bot commented Oct 12, 2021

Codecov Report

Merging #9904 (88fdf9e) into master (f16bfe9) will increase coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #9904   +/-   ##
======================================
  Coverage      93%     93%           
======================================
  Files         178     178           
  Lines       15647   15652    +5     
======================================
+ Hits        14502   14508    +6     
+ Misses       1145    1144    -1     

@mergify mergify bot added the ready PRs ready to be merged label Oct 13, 2021
Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

I definitely think that the automatic logging of the epoch is very useful and that it should stay.
It is extremely useful for converting steps to epochs and vice versa in metric plots as it is monotonic.
I propose to fix this by logging the epoch inside the loop manually at the right place instead of doing it in the connector here. What do you think?

@rohitgr7
Copy link
Contributor Author

@awaelchli epoch will be logged. nothing is changed on the logger side. it's just that we won't be storing that in trainer.logged_metrics because they only contain last logged metrics and epoch is something we add manually inside if it's not logged by user explicitly.
Plus if user do self.log(step=something), we don't log epoch so we can't ensure inside the loop whether to log epoch or not if we move it there.

@awaelchli awaelchli merged commit 0f8fd20 into master Oct 13, 2021
@awaelchli awaelchli deleted the ref/rm_ep_lm branch October 13, 2021 09:30
rohitgr7 added a commit to Tshimanga/pytorch-lightning that referenced this pull request Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logging Related to the `LoggerConnector` and `log()` ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logged metrics and epoch counter at on_epoch_end are out of order
4 participants