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

EvalResult support for val loop (PR 3/5) #2651

Merged
merged 116 commits into from
Jul 22, 2020
Merged

EvalResult support for val loop (PR 3/5) #2651

merged 116 commits into from
Jul 22, 2020

Conversation

williamFalcon
Copy link
Contributor

@williamFalcon williamFalcon commented Jul 20, 2020

Finishes enabling EvalResult in val/test loop (still optional).

Next PR will document all of this.

Additional improvements

Also improves these things:

  • .test() results now includes everything returned by the user (not just callback metrics)
  • When a user wants to track a metric at the step level and epoch level, we automatically split it up:
# user wants to track the val acc for every batch and also the global val acc for the epoch
result.log('val_acc', ..., on_epoch=True, on_step=True)

# automatically becomes
`epoch_val_acc`
`step_val_acc`

@mergify mergify bot requested a review from a team July 20, 2020 23:04
@codecov
Copy link

codecov bot commented Jul 20, 2020

Codecov Report

Merging #2651 into master will increase coverage by 0%.
The diff coverage is 92%.

@@           Coverage Diff           @@
##           master   #2651    +/-   ##
=======================================
  Coverage      91%     92%            
=======================================
  Files          72      74     +2     
  Lines        6129    6316   +187     
=======================================
+ Hits         5597    5786   +189     
+ Misses        532     530     -2     

@pep8speaks
Copy link

pep8speaks commented Jul 21, 2020

Hello @williamFalcon! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-07-22 17:31:30 UTC

@williamFalcon
Copy link
Contributor Author

I was also thinking about that, the only annoying part is that the api for adding histograms is different for each logger, so we would have to enforce the implementation through the base class. That's probably something for a new PR.

yeah that makes sense. I guess for now we can keep global step as is? but for val metrics use this formula:
val_global_step = current_epoch * val_batch_idx

@@ -17,6 +17,8 @@ def is_overridden(self, method_name: str, model: LightningModule = None) -> bool
model = self.get_model()
super_object = LightningModule

# assert model, 'no model passes'
Copy link
Member

@Borda Borda Jul 22, 2020

Choose a reason for hiding this comment

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

just crossed this, what is the case we would pass None as model?
cc: @awaelchli @justusschock @williamFalcon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.test()

Copy link
Member

@Borda Borda Jul 22, 2020

Choose a reason for hiding this comment

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

it is happening also in validation, well in case you call _evalaute directly with passed model

Copy link
Member

Choose a reason for hiding this comment

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

test(model=None) will take the model the trainer knows from fit, right?

Copy link
Member

Choose a reason for hiding this comment

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

yes but in that walk-around test, the model was not assigned to trainer...

@mergify mergify bot requested a review from a team July 22, 2020 15:59
@williamFalcon
Copy link
Contributor Author

actually... we could do this:

val_metric/current_val_epoch

for step metrics. This will make multtiple lines on the same chart. And since val/test loaders are not shuffled, the effect will be a histogram for each batch_idx.

@williamFalcon
Copy link
Contributor Author

but let's merge this in and we can make that change in a follow on PR

@mergify mergify bot requested a review from a team July 22, 2020 16:03
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
@mergify mergify bot requested a review from a team July 22, 2020 16:04
@mergify mergify bot requested a review from a team July 22, 2020 16:04
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.

None yet

4 participants