I’m having the following issue with using Zygote with Optimisers.jl. Here is an MRE:
using Flux, Zygote
m = Chain(Dense(10, 5, relu), Dense(5, 2))
gs = gradient(() -> sum(m(x)), params(m))
opt = ADAM();
Flux.Optimise.update!(opt, params(m), gs)
which returns the error
ERROR: Optimisers.jl cannot be used with Zygote.jl's implicit gradients, `Params` & `Grads`
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] base(dx::Zygote.Grads)
@ Flux ~/.julia/packages/Flux/n3cOc/src/Flux.jl:20
[3] (::Optimisers.var"#13#15"{Params{Zygote.Buffer{Any, Vector{Any}}}})(x̄::Zygote.Grads)
@ Optimisers ~/.julia/packages/Optimisers/1x8gl/src/interface.jl:112
[4] map
@ ./tuple.jl:273 [inlined]
[5] _grads!(dict::IdDict{Optimisers.Leaf, Any}, tree::Optimisers.Adam{Float32}, x::Params{Zygote.Buffer{Any, Vector{Any}}}, x̄s::Zygote.Grads)
@ Optimisers ~/.julia/packages/Optimisers/1x8gl/src/interface.jl:112
[6] update!(::Optimisers.Adam{Float32}, ::Params{Zygote.Buffer{Any, Vector{Any}}}, ::Zygote.Grads)
@ Optimisers ~/.julia/packages/Optimisers/1x8gl/src/interface.jl:70
[7] top-level scope
@ REPL[106]:1