Tony-Y / pytorch_warmup

Learning Rate Warmup in PyTorch
https://tony-y.github.io/pytorch_warmup/
MIT License
386 stars 25 forks source link

Why did my learning rate drop from the initial lr #12

Closed sjchasel closed 1 year ago

sjchasel commented 1 year ago

In every batch, I execute

loss.backward()
optimizer.zero_grad()
optimizer.step()
with warmup_scheduler.dampening():
    lr_scheduler.step()

It doesn't have a warm up process.

Tony-Y commented 1 year ago

Does the example code work in your environment? https://github.com/Tony-Y/pytorch_warmup/blob/master/examples/emnist/main.py

Tony-Y commented 1 year ago

Your code does not optimize model parameters at all because optimizer.zero_grad() is called after loss.backward(). If you cannot understand this, please read the following tutorial:

https://pytorch.org/tutorials/beginner/basics/optimization_tutorial.html#optimizer

Tony-Y commented 1 year ago

Did you solve this issue?