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

how to use lr warmup in traing stage? #198

Closed
seyoulala opened this issue Jan 23, 2024 · 3 comments
Closed

how to use lr warmup in traing stage? #198

seyoulala opened this issue Jan 23, 2024 · 3 comments

Comments

@seyoulala
Copy link

HI The package is amazing! there hava some question when i used package. i want to warmup lr when i used this to training the model but find Trainer class is no paramerter about warmup scheduler

@jrzaurin
Copy link
Owner

Hey @seyoulala thanks for your kind words! :)

I see a number of ways of doing it:

  1. Using multiple trainers: to each trainer you can pass a lr_scheduler (see here). Therefore you could do something like
model = WideDeep(...)
first_scheduler = torch.optim.lr_scheduler.StepLR(...)
warmup_trainer = Trainer(model, objective, lr_schedulers=first_scheduler)
# At this point the weights of the model are "warm"
trainer = Trainer(model, objective, ...). # with a 2nd scheduler if you wanted
  1. Passing a Sequential LR scheduler: in principle, the Trainer accepts any valid pytorch scheduler. Therefore, you could build your own sequential learning rate scheduler and pass it. If this throws an error let me know, because it would be a bug to fix. Personally, I have never tried it (but I will now :) )

  2. And the last one, the fit method allows for a series of warm up parameters 😉. At the moment I implemented two routines. Have a look here, to the finetune parameter, aliased as warmup. Also to this example notebook.

Let me know if you need any more info/help

@seyoulala
Copy link
Author

thanks !build my own learning rate scheduler by SequentialLR of pytorch can deal this problem

@jrzaurin
Copy link
Owner

jrzaurin commented Feb 1, 2024

okay, thanks @seyoulala

@jrzaurin jrzaurin closed this as completed Feb 1, 2024
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

No branches or pull requests

2 participants