Optimisers.jl icon indicating copy to clipboard operation
Optimisers.jl copied to clipboard

Optimizing scalars

Open samanklesaria opened this issue 3 years ago • 1 comments

It seems like Optimisers only works with vectors.

struct WithFloat
    val :: Float64
end
@functor WithFloat

The call to Optimisers.trainable(WithFloat(4)) returns (val = 4.3,), but destructure(WithFloat(4)) produces an empty vector.

Would you accept a pull request allowing destructure to handle scalar parameters?

samanklesaria avatar Jun 28 '22 01:06 samanklesaria

It's not so straightforward, unfortunately. See https://github.com/FluxML/Flux.jl/issues/1991#issuecomment-1148627732 and https://github.com/FluxML/Optimisers.jl/pull/33.

ToucheSir avatar Jun 28 '22 02:06 ToucheSir