This call from a formerly work code seems to throw a method error:
x → maxpool(x, (2,2)),
ERROR: MethodError: no method matching maxpool(::TrackedArray{…,Array{Float32,4}}, ::Tuple{Int64,Int64})
=======
Has the interface for “maxpool” changed? How would I update the following code:
thank you very much
julia> m = Chain(
Conv((5,5), 3=>16, relu),
x → maxpool(x, (2,2)),
Conv((5,5), 16=>8, relu),
x → maxpool(x, (2,2)),
x → reshape(x, :, size(x, 4)),
Dense(200, 120),
Dense(120, 84),
Dense(84, 10),
softmax)
Chain(Conv((5, 5), 3=>16, NNlib.relu), getfield(Main, Symbol(“##9#12”))(), Conv((5, 5), 16=>8, NNlib.relu), getfield(Main, Symbol(“##10#13”))(), getfield(Main, Symbol(“##11#14”))(), Dense(200, 120), Dense(120, 84), Dense(84, 10), NNlib.softmax)
julia> using Flux: crossentropy, Momentum
julia> loss(x, y) = sum(crossentropy(m(x), y))
loss (generic function with 1 method)
julia> opt = Momentum(params(m), 0.01)
┌ Warning: Momentum(params) is deprecated; use Momentum(η::Float64) instead
│ caller = top-level scope at none:0
└ @ Core none:0
#24 (generic function with 1 method)
julia> accuracy(x, y) = mean(onecold(m(x), 1:10) .== onecold(y, 1:10))
accuracy (generic function with 1 method)
julia> epochs = 10
julia> for epoch = 1:epochs
for d in train
l = loss(d…)
back!(l)
opt()
@show accuracy(valX, valY)
end
end
ERROR: MethodError: no method matching maxpool(::TrackedArray{…,Array{Float32,4}}, ::Tuple{Int64,Int64})
Closest candidates are:
maxpool(::TrackedArray, ::PoolDims; kw…) at /Users/chedon/.julia/packages/Tracker/RRYy6/src/lib/array.jl:446
maxpool(::AbstractArray{xT,N}, ::PoolDims; kwargs…) where {xT, N} at /Users/chedon/.julia/packages/TimerOutputs/7zSea/src/TimerOutput.jl:198
Stacktrace:
[1] (::getfield(Main, Symbol(“##9#12”)))( ::TrackedArray{…,Array{Float32,4}} ) at ./REPL[20]:3
[2] applychain( ::Tuple{getfield(Main, Symbol(“##9#12”)),Conv{2,4,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},getfield(Main, Symbol(“##10#13”)),getfield(Main, Symbol(“##11#14”)),Dense{typeof(identity),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}},Dense{typeof(identity),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}},Dense{typeof(identity),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}},typeof(softmax)}, ::TrackedArray{…,Array{Float32,4}} ) at /Users/chedon/.julia/packages/Flux/qXNjB/src/layers/basic.jl:31 (repeats 2 times)
[3] (::Chain{Tuple{Conv{2,4,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},getfield(Main, Symbol(“##9#12”)),Conv{2,4,typeof(relu),TrackedArray{…,Array{Float32,4}},TrackedArray{…,Array{Float32,1}}},getfield(Main, Symbol(“##10#13”)),getfield(Main, Symbol(“##11#14”)),Dense{typeof(identity),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}},Dense{typeof(identity),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}},Dense{typeof(identity),TrackedArray{…,Array{Float32,2}},TrackedArray{…,Array{Float32,1}}},typeof(softmax)}})( ::Array{Float32,4} ) at /Users/chedon/.julia/packages/Flux/qXNjB/src/layers/basic.jl:33
[4] loss( ::Array{Float32,4}, ::Flux.OneHotMatrix{Array{Flux.OneHotVector,1}} ) at ./REPL[22]:1
[5] top-level scope at ./REPL[26]:3 [inlined]
[6] top-level scope at ./none:0