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

Does `functor` have the right semantics for Flux?

Open CarloLucibello opened this issue 3 years ago • 6 comments

Due to the default fallback

functor(T, x) = (), _ -> x

in Functors.jl, every custom type is considered a leaf (i.e. it has no children) and we have to sprinkle @functor MyType everywhere in Flux and in user code. We could remove all this boilerplate by having by default what @functor MyType currently does. Then 99% of people could live their life completely unaware of @functor/functor (historically poorly documented and poorly understood) and only use the much clearer trainable(x::MyType) in case they need to customize the parameter collection.

Besides the transition, which I think could be made rather smooth, does anyone see any counterindication in changing the default?

CarloLucibello avatar Oct 11 '21 20:10 CarloLucibello