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

Linear warmup sched #138

Merged
merged 27 commits into from
Aug 5, 2020
Merged

Linear warmup sched #138

merged 27 commits into from
Aug 5, 2020

Conversation

ananyahjha93
Copy link
Contributor

@ananyahjha93 ananyahjha93 commented Aug 3, 2020

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

What does this PR do?

Fixes # (issue).

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 🙃

@pep8speaks
Copy link

pep8speaks commented Aug 3, 2020

Hello @ananyahjha93! Thanks for updating this PR.

Line 100:80: W504 line break after binary operator
Line 101:72: W504 line break after binary operator
Line 102:84: W504 line break after binary operator
Line 103:72: W504 line break after binary operator

Comment last updated at 2020-08-05 17:59:48 UTC

@mergify mergify bot requested a review from Borda August 3, 2020 18:24
def _test_against_closed_form(self, scheduler, closed_form_scheduler, epochs=10):
targets = []
for epoch in range(epochs):
closed_form_scheduler.step(epoch)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this comes from earlier versions of pytorch where scheduler.step() was called before the epoch instead of after.

Copy link
Member

Choose a reason for hiding this comment

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

but do we still support these old versions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@justusschock current version of pytorch still defines _test_against_closed_form() for now, all we need to do is define that function to support the old version. I have a warning and doc available for this

@codecov
Copy link

codecov bot commented Aug 4, 2020

Codecov Report

Merging #138 into master will increase coverage by 0.17%.
The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #138      +/-   ##
==========================================
+ Coverage   91.14%   91.32%   +0.17%     
==========================================
  Files          82       86       +4     
  Lines        4056     4172     +116     
==========================================
+ Hits         3697     3810     +113     
- Misses        359      362       +3     
Flag Coverage Δ
#unittests 91.32% <93.33%> (+0.17%) ⬆️

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

Impacted Files Coverage Δ
pl_bolts/optimizers/lr_scheduler.py 93.10% <93.10%> (ø)
pl_bolts/optimizers/__init__.py 100.00% <100.00%> (ø)
pl_bolts/models/rl/per_dqn_model.py 80.00% <0.00%> (-0.49%) ⬇️
...bolts/models/self_supervised/amdim/ssl_datasets.py 75.36% <0.00%> (-0.36%) ⬇️
pl_bolts/models/rl/dqn_model.py 82.17% <0.00%> (-0.18%) ⬇️
.../models/autoencoders/basic_vae/basic_vae_module.py 92.78% <0.00%> (-0.15%) ⬇️
..._bolts/models/self_supervised/moco/moco2_module.py 85.32% <0.00%> (-0.14%) ⬇️
pl_bolts/models/self_supervised/cpc/cpc_module.py 80.82% <0.00%> (-0.14%) ⬇️
...lts/models/self_supervised/simclr/simclr_module.py 91.05% <0.00%> (-0.08%) ⬇️
pl_bolts/models/self_supervised/cpc/networks.py 94.59% <0.00%> (-0.05%) ⬇️
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac363dd...ce206aa. Read the comment docs.

@Borda Borda added the enhancement New feature or request label Aug 4, 2020
@ananyahjha93
Copy link
Contributor Author

@Borda feedback on formatting as well, used https://github.com/psf/black on @nateraw 's advice.

@ananyahjha93 ananyahjha93 changed the title [wip] Linear warmup sched Linear warmup sched Aug 4, 2020
pl_bolts/optimizers/lr_scheduler.py Show resolved Hide resolved
pl_bolts/optimizers/lr_scheduler.py Outdated Show resolved Hide resolved
pl_bolts/optimizers/lr_scheduler.py Outdated Show resolved Hide resolved
from pl_bolts.optimizers.lr_scheduler import LinearWarmupCosineAnnealingLR


EPSILON = 1e-12
Copy link
Member

Choose a reason for hiding this comment

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

I think there is an epsilon defined somewhere in lightning iirc, maybe use this to avoid duplication?

cc @Borda who might know, where it is ^^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Borda so I had this question about default epsilons in lightning, numpy.finfo(numpy.float32).eps is 1.1920929e-07. Since learning rates used are up to 1e-6, we need a higher precision in schedulers. But, numpy.finfo(numpy.float64).eps comes out to be 2.220446049250313e-16, which results in failing tests. So the ideal epsilon seemed 1e-12.

def _test_against_closed_form(self, scheduler, closed_form_scheduler, epochs=10):
targets = []
for epoch in range(epochs):
closed_form_scheduler.step(epoch)
Copy link
Member

Choose a reason for hiding this comment

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

but do we still support these old versions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants