-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Refactor result handling in training loop #7506
Conversation
Hello @awaelchli! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-05-12 22:18:05 UTC |
for more information, see https://pre-commit.ci
Codecov Report
@@ Coverage Diff @@
## master #7506 +/- ##
=======================================
- Coverage 92% 88% -4%
=======================================
Files 199 198 -1
Lines 13068 12837 -231
=======================================
- Hits 12026 11269 -757
- Misses 1042 1568 +526 |
…nto refactor/training-loop-result
for more information, see https://pre-commit.ci
def log_metrics(self, metrics, grad_norm_dict, step=None): | ||
"""Logs the metric dict passed in. | ||
If `step` parameter is None and `step` key is presented is metrics, | ||
uses metrics["step"] as a step | ||
|
||
Args: | ||
metrics (dict): Metric values | ||
grad_norm_dic (dict): Gradient norms | ||
grad_norm_dict (dict): Gradient norms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could add typehints to signature to reflect docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, logger connector will be refactored
the only reason my PR touches this class is because I auto-renamed the variable everywhere.
return AttributeDict( | ||
signal=0, | ||
grad_norm_dic=grad_norm_dic, | ||
grad_norm_dict={}, | ||
training_step_output_for_epoch_end=batch_outputs, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want this more strongly typed as a dataclass instead of AttributeDict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes good idea and attribute dict has to change as part of our refactor efforts anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM !
What does this PR do?
Minor refactor, restores a tiny bit of sanity.
Removes the following state on TrainLoop:
_cur_step_result
_cur_grad_norm_dic
Fixes typo in spelling of
grad_norm_dict
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:
Did you have fun?
Make sure you had fun coding 🙃