Preamble/Disclaimer:
This topic is about syntactic sugar that I find missing. I know that these tasks are not hard to accomplish in other ways.
I often find that my assumptions about what functions extend to what types, are wrong.
I wonder if there is a special reason for what I naïvely think of as lacunae in julia, or is it just that nobody got around to it?
Here’s an example. I knew I could iterate over a Flux.chain
(e.g. for layer ∈ myfluxchain
) so I tried the same with Flux.parallel and discovered that that doesn’t work.
I sometimes find myself patching such holes, but perhaps there are reasons I haven’t thought of why I shouldn’t.
For completeness, here is the (admittedly trivial) “patch”:
function Base.iterate(p::Flux.Parallel, s = nothing)
ks = keys(p)
if isnothing(s)
rv = iterate(ks)
else
rv = iterate(ks, s)
end
if isnothing(rv)
return nothing
end
k, s = rv
return (p[k], s)
end