Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Pass task reference ParamScheculer.__call__ #397

Open
miguelvr opened this issue Feb 19, 2020 · 3 comments
Open

Pass task reference ParamScheculer.__call__ #397

miguelvr opened this issue Feb 19, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@miguelvr
Copy link
Contributor

🚀 Feature

We should pass a reference to the task object to the optimizer + param scheduler to be able to use more complex parameter schedulers

Motivation / Pitch

Basic PyTorch learning rate schedulers such as the ReduceLROnPlateau require task information such as access to the validation loss. Currently, it is not possible to implement this in Classy Vision because there is no access to the task by the scheduler.

By adding a task reference, the user could access the local variables, or the task meters to make informed decisions on their parameter scheduling.

This would imply also giving the optimizer access to the task during the update scheduler method.

Alternatives

As far as I know, the only (hacky) way of achieving this is by using a custom hook, but hooks are not configurable via configuration file, and it doesn't make much sense to have a Parameter Scheduler as a Hook.

Let me know what you think!

@vreis
Copy link
Contributor

vreis commented Feb 19, 2020

This is a recurring issue -- thanks for filing this.

Instead of adding a dependency between task/scheduler, I wanted to introduce a global object to give you access to the task currently being trained (we can only have one at a time anyway). That would solve your issue, right?

@vreis vreis added the enhancement New feature or request label Feb 19, 2020
@miguelvr
Copy link
Contributor Author

I guess so... I'm not a fan of global objects, however. I don't see much harm in passing the task reference as an argument, except maybe for compatibility issues.

Would that solution work for custom train scripts other than the provided classy_train?

Maybe the trainer can set the global variable and have an importable function that gets it? Something similar to what flask does

@Pedrexus
Copy link

Hi, Folks. Any updates on this end? Is there a way to use ReduceLROnPlateau with ClassyVision?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants