-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Fix learning rate scheduler being unexpectedly overwritten by optimizer's default value #16487
Fix learning rate scheduler being unexpectedly overwritten by optimizer's default value #16487
Conversation
python/mxnet/optimizer/optimizer.py
Outdated
self.lr = learning_rate | ||
if self.lr_scheduler is not None and learning_rate is not None: | ||
if self.lr_scheduler.base_lr != learning_rate: | ||
raise UserWarning("learning rate from ``lr_scheduler`` has been " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this terminate the execution and start the exception handling? If so, the statement below wouldn't be executed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the fix : )
The default lr should be presented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you : )
Hello,
learning rate from
I hope I didn't miss anything before coming to you. can you please suggest what should be done in such scenario? |
@MrRaghav it looks like an out of memory issue that is different from what this PR is about. It would be best if you could create a new issue for it and I will try to help there. Thanks |
Thank you. I have created one: #18662 |
Description
Right now the following example (similar as from dmlc/gluon-cv#750) yields surprising and unexpected output:
In the current implementation of optimizer, mxnet overwrite the learning rate scheduler's learning rate with the optimizer's learning rate by
Therefore, when users define a learning rate scheduler, and use it as the parameter of the optimizer, they are going to surprisingly find that the learning rate has been overwritten by the default value,
0.01
.My patch set default
learning_rate
toNone
, and assign the original0.01
to it only in the absence oflr_scheduler
.Checklist
Essentials
Please feel free to remove inapplicable items for your PR.