Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add more options to create_supervised_trainer #1235

Closed
vfdev-5 opened this issue Aug 14, 2020 · 8 comments · Fixed by #1589
Closed

Add more options to create_supervised_trainer #1235

vfdev-5 opened this issue Aug 14, 2020 · 8 comments · Fixed by #1589

Comments

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Aug 14, 2020

🚀 Feature

Idea is to add more options to create_supervised_trainer helper:

For Hacktoberfest/PyDataGlobal contributors, feel free to ask questions for details if any and say that you would like to tackle the issue.
Please, take a look at CONTRIBUTING guide.

@apthagowda97
Copy link

I would like to work on this.

@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Oct 3, 2020

@apthagowda97 sure, please go ahead. I assign you to this issue

@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Oct 6, 2020

@apthagowda97 any updates on this ? Anyway, do not hesitate to ask question if something is not clear about the issue.

@apthagowda97
Copy link

By going through issue #419 its best to add gradient clipping to contrib.engines as discussed compared with changing create_supervised_trainer. Should I name it create_supervised_gc_trainer?

@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Oct 7, 2020

@apthagowda97 I think it is better let's keep the same name and add the options. Such that there is one multi-option helper function.

@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Oct 17, 2020

@apthagowda97 any updates on this issue ?

@apthagowda97
Copy link

apthagowda97 commented Oct 18, 2020

Sorry I was busy from past few days. I ll try to finish it Asap.

@apthagowda97 apthagowda97 removed their assignment Oct 26, 2020
@vfdev-5 vfdev-5 added PyDataGlobal PyData Global 2020 Sprint and removed Hacktoberfest labels Oct 31, 2020
@vfdev-5 vfdev-5 removed the PyDataGlobal PyData Global 2020 Sprint label Dec 14, 2020
@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Feb 12, 2021

Cross-posted from #1589


We discussed this PR and related issue with the team and we think that we should explore a bit different approach. Helper method create_supervised_trainer is roughly made of 2 things : update function definition and Engine setup.

Probably, it would more helpful to provide public methods like:

  • supervised_training_step
  • supervised_training_step_tpu
  • supervised_training_step_apex
  • supervised_training_step_amp

and inside create_supervised_trainer we could setup the trainer according to provided options without lots of if/else. Maybe, we can skip for instance grad norm.

Basically, the idea is something like that :

def get_training_step_1(a):
    def training_step(e, b):
        print(a, e, b)
    return training_step
    
def get_training_step_2(a):
    def training_step(e, b):
        print(a, e, b, "with amp")
    return training_step

def create_supervised_trainer(a, opt):
    training_step = None
    if opt == 1:
        training_step = get_training_step_1(a)
    elif opt == 2:
        training_step = get_training_step_2(a)
        
    e = Engine(training_step)
    return e  

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants