-
Notifications
You must be signed in to change notification settings - Fork 378
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
Problems when using custom learning rate scheduler for NeuralForecast Models #1096
Comments
Maybe @JQGoh, @jmorales, @BrunoBelucci you have some idea of how to solve it? |
Hello! Can you send a code snippet of OneCycle that works and one for ReduceLROnPlateau to reproduce on my end? Thanks! |
Hello, To the best of my knowledge, it is not currently possible to use ReduceLROnPlateau out-of-the-box with the existing implementation of neuralforecast. As mentioned in this comment, this would require the user to provide a "lr_scheduler_config," which is not directly supported at this time. This "lr_scheduler_config" should be returned by the configure_optimizers method in Lightning (refer to this documentation for more details). In the "lr_scheduler_config," you need to specify the "monitor" parameter with the metric you're tracking to detect the plateau. Typically, the "interval" is also set to "epoch" because the plateau is usually identified per epoch rather than per step, though this may vary depending on your model. Currently, I am not using neuralforecast with ReduceLROnPlateau, so I cannot offer an immediate solution. However, based on our previous discussion in #998, I believe the simplest workaround for now is to monkey-patch the configure_optimizers function of your model to return a dictionary as expected by Lightning. This dictionary should include an "optimizer" key and, optionally, a "lr_scheduler" key, which can be a single LR scheduler or a lr_scheduler_config (as specified in the documentation). If you do not manage to solve this, you can provide me a minimum (not) working example and I can see if I can fix it for you during my free time. Regards, |
Thank you so much for your explanations and looking into how to resolve the issue!! Below a code snippet that (a) works with OneCycleLR and (b) that reproduces the error with ReduceLRonPlateau.
a. - OneCycleLR
b. -ReduceLROnPlateau
ERROR MESSAGE
|
@MLfreakPy Nevertheless, you could check out this branch #1015 and install the the dev-version of neuralforecast. This allows you to call |
Thank you very much @JQGoh!! I will use this dev-version and your example for implementation 👍 This flexibility in configuring the optimizers is amazing :) |
@JQGoh I tried to manipulate the
|
@MLfreakPy But do take note that because my forked repository does not always sync with the original repository master, it is better you could copy the key changes as detailed in #1015 to the local copy of your source code, if you want to use the latest updated neuralforecast library. @jmoralez |
Hey. I think we can introduce that method and deprecate the arguments |
@jmoralez That sounds great😊 |
What happened + What you expected to happen
Hi together,
first, thank you so much for the implementation of a custom lr scheduler!
I ran into problems employing a
ReduceLROnPlateau
scheduler.Currently I am passing through the
lr_scheduler
andlr_scheduler_kwargs
parameters. However, I get the below error when implementing ReduceLROnPlateau. Other schedulers, like OneCycle, work perfectly though! I think some of your earlier discussion evolved around it, however, I couldn't make it work yet.[(https://github.com//pull/998)]
MisconfigurationException('The lr scheduler dict must include a monitor when a ReduceLROnPlateau scheduler is used. For example: {"optimizer": optimizer, "lr_scheduler": {"scheduler": scheduler, "monitor": "your_loss"}}').
Versions / Dependencies
GoogleColab
neuralforecast
Version: 1.7.4
Reproduction script
See above - if needed happy to supply more details.
Issue Severity
Medium: It is a significant difficulty but I can work around it.
The text was updated successfully, but these errors were encountered: