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

Different learning rate per layer #10

Closed
Kalkasas opened this issue Jul 21, 2016 · 4 comments
Closed

Different learning rate per layer #10

Kalkasas opened this issue Jul 21, 2016 · 4 comments
Labels
usage usage of tensorpack / how-to questions

Comments

@Kalkasas
Copy link

For tensorflow you can use multiple optimizers to achieve different learning rates per layer.
Is there support for this in tensorpack or do I have to write a custom trainer?

@ppwwyyxx
Copy link
Collaborator

ppwwyyxx commented Jul 21, 2016

Yes, you can specify different learning rate for each parameter, by scaling its gradient. You can overwrite the get_gradient_processor() method in your Model with something like:

    def get_gradient_processor(self):
        return [ScaleGradient([('conv.*/W', 0.5), ('fc.*', 2)])]

ScaleGradient takes a list of (regex, multiplier) tuple. Parameters that are scaled will get printed out so you could check.

// UPDATE: this usage was later deprecated. See comment below.

@Kalkasas
Copy link
Author

Exactly what I needed. Thank you!

@ppwwyyxx ppwwyyxx added question usage usage of tensorpack / how-to questions and removed question labels Dec 21, 2016
@coolbay
Copy link

coolbay commented Mar 4, 2018

I couldn't find any function as get_gradient_processor() in the base class ModelDesc. I tried adding this function into my Model, but it seemed that this function was never called.

@ppwwyyxx
Copy link
Collaborator

ppwwyyxx commented Mar 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
usage usage of tensorpack / how-to questions
Projects
None yet
Development

No branches or pull requests

3 participants