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

Chain forgets names under fmap #1857

Closed
mcabbott opened this issue Feb 4, 2022 · 0 comments · Fixed by #1862
Closed

Chain forgets names under fmap #1857

mcabbott opened this issue Feb 4, 2022 · 0 comments · Fixed by #1862

Comments

@mcabbott
Copy link
Member

mcabbott commented Feb 4, 2022

From FluxML/Optimisers.jl#49 (comment), this isn't great:

julia> fmap(identity, Chain(x=sin, y=cos))
Chain(sin, cos)

The culprit is this functor method, which could be extended to deal with this.

functor(::Type{<:Chain}, c) = c.layers, ls -> Chain(ls...)

Or we could delete it, and let Chain be more like Parallel:

julia> Flux.functor(Chain(x=sin, y=cos))
((x = sin, y = cos), Flux.var"#154#155"())

julia> Flux.functor(Parallel(vcat, (x=sin, y=cos)))
((connection = vcat, layers = (x = sin, y = cos)), Flux.var"#178#179"())

Then we would want delete the inner constructor for Chain, so that it accepts a tuple, Chain((sin, cos)) == Chain(sin, cos). That would line up with #1809 allowing Chain([sin, cos]) as a type-unstable variant.

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

Successfully merging a pull request may close this issue.

1 participant