-
Notifications
You must be signed in to change notification settings - Fork 82
Add support for recursing Chains in ReactantCompatibleOptimisers #1622
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,22 @@ function Optimisers.init( | |
| return zero(x), zero(x), Utils.convert_eltype.((T,), opt.opt.beta), zero(x) | ||
| end | ||
|
|
||
| # Recurse through chains | ||
| function Optimisers.adjust( | ||
| chain::ReactantOptimiser{<:Optimisers.OptimiserChain}, | ||
| eta::Real | ||
| ) | ||
| results = Optimisers.OptimiserChain([Optimisers.adjust(opt, eta) for opt in chain.opt.opts]...) | ||
| return ReactantOptimiser(results) | ||
| end | ||
| function Optimisers.adjust( | ||
| chain:ReactantOptimiser{<:Optimisers.OptimiserChain}; | ||
| kw... | ||
| ) | ||
|
Comment on lines
+51
to
+61
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will overloading
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could be done that way, but there would be more duplicated code since the implementation would end up replicating the recursion code already present in |
||
| results = Optimisers.OptimiserChain([Optimisers.adjust(opt; kw...) for opt in chain.opt.opts]...) | ||
| return ReactantOptimiser(results) | ||
| end | ||
avik-pal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| function Optimisers._adjust(opt::ReactantOptimiser, nt::NamedTuple) | ||
| dev = with_track_numbers(get_device(opt), AbstractFloat) | ||
| return ReactantOptimiser(Optimisers._adjust(opt.opt, dev(nt))) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.