You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I constructed the layer called MinMaxScale, and when I tried to use Flux.Chain() to chain the Dense layer and MinMaxScale layer, I got the method error about the empty collection.
Steps to Reproduce
using Flux
struct MinMaxScale end
Flux.@functor MinMaxScale
function (l::MinMaxScale)(x::AbstractArray)
minx, maxx = extrema(x)
return (x .- minx) ./ (maxx - minx)
end
function Base.show(io::IO, l::MinMaxScale)
print(io, "MinMaxScale")
end
encoder = Chain(
Dense(100 => 10, gelu),
Dense(10 => 1, gelu),
MinMaxScale()
)
Expected Results
The model should be worked
Observed Results
Got Method error
MethodError: reducing over an empty collection is not allowed; consider supplying init to the reducer
This is a bug. Somewhere in show.jl there's a sum which should have init=0 or something?
But the minimal work-around is not to call @functor MinMaxScale. Since it does not wrap any parameters, there should be no need for Functors to walk inside it.
Package Version
0.13.14
Julia Version
1.8.2
OS / Environment
Windows 10
Describe the bug
I constructed the layer called MinMaxScale, and when I tried to use
Flux.Chain()
to chain the Dense layer and MinMaxScale layer, I got the method error about the empty collection.Steps to Reproduce
Expected Results
The model should be worked
Observed Results
Got Method error
Relevant log output
The text was updated successfully, but these errors were encountered: