jdonnelly36 / Deformable-ProtoPNet

The official repository for Deformable ProtoPNet, as described in "Deformable ProtoPNet: An Interpretable Image Classifier Using Deformable Prototypes".
MIT License
37 stars 11 forks source link

UserWarning: Detected call of lr_scheduler.step() before optimizer.step() #6

Closed xymyys closed 1 year ago

xymyys commented 1 year ago

Hi, When the code runs to the fifth epoch, a warning appears: /home/hi/anaconda3/envs/CTracker/lib/python3.7/site-packages/torch/optim/lr_scheduler.py:134: UserWarning: Detected call of lr_scheduler.step() before optimizer.step(). In PyTorch 1.1.0 and later, you should call them in the opposite order: optimizer.step() before lr_scheduler.step(). Failure to do this will result in PyTorch skipping the first value of the learning rate schedule. See more details at https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate "https://pytorch.org/docs/stable/optim.html#how-to-adjust-learning-rate", UserWarning)

How should I change the code to eliminate this warning? Otherwise, the learning rate will be affected.

jdonnelly36 commented 1 year ago

Hello,

Thank you for pointing this out, and apologies for the delayed response. I've pushed a fix to the main branch -- please see commit e6a7d39 for the fix.