Skip to content
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

Advice on gradient clipping #375

Closed
willprice opened this issue Dec 20, 2018 · 2 comments
Closed

Advice on gradient clipping #375

willprice opened this issue Dec 20, 2018 · 2 comments

Comments

@willprice
Copy link
Contributor

Using ignite.engine.create_supervised_trainer I'm unable to clip my gradients as this falls between the steps:

loss.backward()
# gradient clip
optimizer.step()

There are no event's fired between these two pieces of code. Gradient clipping and other manipulation techniques are quite common. It'd be nice if Ignite supported these. Is there a recommended way of doing this? Or is it just a case of constructing my own Engine with a process_fn similar to that constructed by create_supervised_trainer? Are there any plans to create events that allow one to do this sort of thing with create_supervised_trainer?

Cheers for the awesome lib!

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Dec 20, 2018

@willprice thanks for the feedback!

Concering your problem I would advise (see Concepts) to use directly Engine with custom process_fn without complicating the system with custom events.
Methods like create_supervised_trainer are just helper methods for a basic usage.

HTH

@willprice
Copy link
Contributor Author

Hi @vfdev-5,
Thanks for the quick response and advice, makes sense!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants