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

How to use momentum and weightdecay #106

Closed
baggepinnen opened this issue Nov 13, 2017 · 3 comments
Closed

How to use momentum and weightdecay #106

baggepinnen opened this issue Nov 13, 2017 · 3 comments

Comments

@baggepinnen
Copy link
Contributor

I have been trying to figure out how to use the weightdecay function and the Momentum optimizer.
It seems weightdecay should be passed to the optimiser function, e.g., when an optimizer is created. None of the optimizers do however have an option to pass in a weight decay parameter. Am I supposed to create a separate optimizer for weight decay and momentum that is called before the optimizer that calls descent?

@MikeInnes
Copy link
Member

The optimiser APIs are pretty clumsy right now; they are supposed to be composable but it doesn't quite work. I'll take a look at redesigning this soon.

@baggepinnen
Copy link
Contributor Author

I did manage to compose an optimizer with weight decay now when a Vector of optimizers is accepted by train!, but the code did not look pretty...

opt  = [ADAM(params(m), 0.01, decay=0.001); [weightdecay(Param(p), 0.002) for p in params(m) if isa(p, AbstractMatrix)]]

@MikeInnes
Copy link
Member

Hopefully this is easier since #379.

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