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

Explicitly calling the optimizers #228

Closed
jbrea opened this issue Apr 9, 2018 · 1 comment
Closed

Explicitly calling the optimizers #228

jbrea opened this issue Apr 9, 2018 · 1 comment

Comments

@jbrea
Copy link

jbrea commented Apr 9, 2018

There are situations where I would like to call the optimizer explicitly, e.g. opt(params, grad) or update!(params, grad, opt). I think this could be achieved while maintaing modularity with e.g.

mutable struct Momentum
    ρ
    η
    v
    schedule
end
function (m::Momentum)(g)
    m.schedule(m)
    @. m.v = m.ρ * m.v - m.η * g
end

mutable struct SGD
    η
    momentum
    schedule
end
function (opt::SGD)(p, g)
    opt.schedule(opt)
    @. p -= opt.η * opt.momentum(g)
end

where schedule could be expdecay or invdecay.
What do you think?

@MikeInnes
Copy link
Member

Addressed by #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