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

optim_low breaks if some parameter in the model has None gradient #40

Closed
ksreenivasan opened this issue Jan 5, 2021 · 2 comments
Closed

Comments

@ksreenivasan
Copy link
Contributor

In the step() method here, if p.grad = None, then this line will break causing the optimizer to crash. However, in several Deep Learning applications, it is common to have some parameters within a layer or even whole layers to be frozen. QPyTorch's optimizer would not be applicable to these cases.

PyTorch's default optimizer has a simple and elegant solution which is to just skip these parameters treating None has equivalent to 0 gradient. We have implemented this solution here. I would like to propose this change to QPyTorch as well.

@Tiiiger
Copy link
Owner

Tiiiger commented Jan 5, 2021

hi @kamikazekartik thank you for your suggestion! if you can help fix it and submit a PR, I am happy to merge it. Otherwise it might take a while before I get to it.

@ksreenivasan
Copy link
Contributor Author

Sounds good @Tiiiger! It's just a few lines of code, so I'll make the change and create a PR later today.

Tiiiger added a commit that referenced this issue Jan 6, 2021
[#40] Allowing optimizer.step to handle None gradients
@Tiiiger Tiiiger closed this as completed Jan 6, 2021
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