-
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
Add tracking of basic states in Trainer [wip - to-be-merged after v0.9] #2541
Add tracking of basic states in Trainer [wip - to-be-merged after v0.9] #2541
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2541 +/- ##
========================================
+ Coverage 58% 90% +32%
========================================
Files 79 80 +1
Lines 7281 7282 +1
========================================
+ Hits 4245 6574 +2329
+ Misses 3036 708 -2328 |
This pull request is now in conflict... :( |
68bddde
to
17947ab
Compare
@@ -397,6 +399,7 @@ def train(self): | |||
# user could press ctrl+c many times... only shutdown once | |||
if not self.interrupted: | |||
self.interrupted = True |
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.
I guess that self.interrupted
can be removed in the future?
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.
ye, more of them could be cleaned...
I was thinking maybe it would be better and cleaner if we made these state updates in decorators and add the decorators to methdods like the training loop, validation loop etc. |
Hi @awaelchli! Yes I think it could look nicer with decorators, I try to implement it and mention you as soon as it's ready. |
ummm. can you give an example? |
@williamFalcon my idea is something like this to wrap run functions (fit, test). However it requires a little bit of restructuring =)
|
17947ab
to
4d533ed
Compare
This pull request is now in conflict... :( |
c94404f
to
47b3c6a
Compare
Sure. I could do it as well. Next PR |
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
…ack to a trainer.
…e, add tests for decorator only.
4af5fdd
to
b512b05
Compare
b512b05
to
f9f762e
Compare
@zerogerc one test was failing, but it seems unrelated, so I have just rebased it again, let's see if it helps... |
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 - just a quick question...
@@ -396,6 +397,7 @@ def __init__( | |||
self.interrupted = False | |||
self.should_stop = False | |||
self.running_sanity_check = False | |||
self.state = TrainerState.INITIALIZING |
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.
Here you set trainer's self.state
to TrainerState.INITIALIZING
...(see next comment)
return self.state | ||
|
||
trainer = Trainer(default_root_dir=tmpdir) | ||
trainer.state = TrainerState.INITIALIZING |
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.
Why are you setting trainer.state = TrainerState.INITIALIZING
if its set in the init of Trainer? Should this be ==
?
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.
trainer.state = TrainerState.INITIALIZING |
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.
Could be wrong, just let me know what's going on here 😄
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.
Very good point by nate, we should make the state read only property! and only the trainer should to write to the internal attribute trainer._state
@williamFalcon said he wants to wait with this, so we should probably wait for his approval before automerging |
yes, this goes after v0.9, so I ll put there wip just in case... |
This pull request is now in conflict... :( |
this looks great! let's merge it |
I know that's why we made it =) just you we a bit conservative and leave it for 0.9.1 |
What does this PR do?
Fixes #1633
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
Did you have fun?
Make sure you had fun coding 🙃