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

Support for complex LR scheduler configuration #125

Merged
merged 8 commits into from
Aug 4, 2023

Conversation

hrukalive
Copy link

@hrukalive hrukalive commented Aug 4, 2023

Recursively construct objects if cls is present in sub-arguments. This means that complex schedulers such as SequentialLR str possible. The following is a demo config:

lr_scheduler_args:
  scheduler_cls: torch.optim.lr_scheduler.ChainedScheduler
  schedulers:
  - cls: torch.optim.lr_scheduler.SequentialLR
    schedulers:
    - cls: torch.optim.lr_scheduler.StepLR
      step_size: 10
    - cls: torch.optim.lr_scheduler.CosineAnnealingWarmRestarts
      T_0: 10
    milestones:
    - 10
  - cls: torch.optim.lr_scheduler.SequentialLR
    schedulers:
    - cls: torch.optim.lr_scheduler.ExponentialLR
      gamma: 0.5
    - cls: torch.optim.lr_scheduler.LinearLR
    - cls: torch.optim.lr_scheduler.MultiStepLR
      milestones:
      - 10
      - 20
    milestones:
    - 10
    - 20

Meanwhile, the side effect of supporting the complex configuration is that the LR scheduler state in the checkpoint is deprecated. The new learning rate will be calculated according to the latest configurations before training starts.

Warning:

Nested SequentialLR and ChainedScheduler have unexpected behavior. DO NOT nest them. Also, make sure the scheduler is chainable from the doc before using it in the ChainedScheduler.

@hrukalive hrukalive added the enhancement New feature or request label Aug 4, 2023
@hrukalive hrukalive requested a review from yqzhishen August 4, 2023 05:35
@hrukalive hrukalive self-assigned this Aug 4, 2023
@yqzhishen
Copy link
Member

There are conflicts after merging #120 into main

@hrukalive hrukalive marked this pull request as ready for review August 4, 2023 21:39
@hrukalive hrukalive merged commit 7f4f515 into openvpi:main Aug 4, 2023
@hrukalive hrukalive deleted the complex_lr_scheduler branch August 17, 2023 20:19
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.

2 participants