Skip to content

1014 learning rate finder#1454

Merged
rijobro merged 35 commits into
Project-MONAI:masterfrom
rijobro:learning_rate
Jan 26, 2021
Merged

1014 learning rate finder#1454
rijobro merged 35 commits into
Project-MONAI:masterfrom
rijobro:learning_rate

Conversation

@rijobro

@rijobro rijobro commented Jan 15, 2021

Copy link
Copy Markdown
Contributor

Fixes #1014.

Description

Implements calculation of optimal learning rate based on https://github.com/davidtvs/pytorch-lr-finder.

image

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh --codeformat --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@Nic-Ma Nic-Ma changed the title learning rate finder 1014 learning rate finder Jan 18, 2021
@Nic-Ma Nic-Ma changed the title 1014 learning rate finder [WIP] 1014 learning rate finder Jan 18, 2021
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@rijobro rijobro marked this pull request as ready for review January 18, 2021 17:20
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@rijobro rijobro changed the title [WIP] 1014 learning rate finder 1014 learning rate finder Jan 20, 2021
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@rijobro

rijobro commented Jan 21, 2021

Copy link
Copy Markdown
Contributor Author

@wyli @Nic-Ma @ericspod this part of the PR saves the state of the network and optimiser to disk or memory, such that they can be restored at the end.

Does this functionality live somewhere else in MONAI?

@ericspod

Copy link
Copy Markdown
Member

We had that kind of functionality as part of an Ignite handler for saving checkpoints, but that's not quite how you're doing things here.

@wyli wyli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks @rijobro this is very useful!

Perhaps the way the training losses is computed/accumulated (self._train_batch) should be decoupled from the lr_finder. Intuitively I think the LR finder should work fine as long as the user provides a black box that takes lr/step as input, and returns a total_loss (e.g. self._train_batch and self._validate). Do you want to refactor this PR to decouple those? otherwise we could file a ticket and have another iteration.

pls see also some minor suggestions inline, they are mostly optional

@Can-Zhao would be great to have your comments as well!

Comment thread monai/optimizers/lr_finder.py Outdated
Comment thread monai/optimizers/lr_finder.py
Comment thread monai/optimizers/lr_finder.py Outdated
Comment thread monai/optimizers/lr_finder.py Outdated
Comment thread monai/optimizers/lr_finder.py Outdated
Comment thread monai/optimizers/lr_finder.py Outdated
Comment thread monai/optimizers/lr_finder.py Outdated
Comment thread monai/optimizers/lr_finder.py Outdated
Comment thread monai/optimizers/lr_finder.py Outdated
@rijobro

rijobro commented Jan 21, 2021

Copy link
Copy Markdown
Contributor Author

@wyli thanks, I'll get to it!

Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@rijobro rijobro mentioned this pull request Jan 22, 2021
6 tasks
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@rijobro

rijobro commented Jan 25, 2021

Copy link
Copy Markdown
Contributor Author

@wyli this is ready if you want to review again, thanks!

@wyli wyli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks, it looks good, except some minor warnings on (object) https://deepsource.io/gh/Project-MONAI/MONAI/run/a53a8313-ab56-4aea-8a8b-e6fd4941f978/python/PYL-R0205 this new feature needs another iteration to decouple the actual training/validation logic_train_batch and _validate from the LearningRateFinder class

Signed-off-by: Richard Brown <33289025+rijobro@users.noreply.github.com>
@rijobro rijobro merged commit a2da8a1 into Project-MONAI:master Jan 26, 2021
@rijobro rijobro deleted the learning_rate branch January 26, 2021 11:31
@rijobro rijobro mentioned this pull request Jan 26, 2021
7 tasks
@andre-fs-ferreira

Copy link
Copy Markdown
Contributor

I am having trouble using this class for GANs. Is there any way to do something similar to the "GANLearner" fastai?

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.

learning rate finder

4 participants