Tracker.jl icon indicating copy to clipboard operation
Tracker.jl copied to clipboard

Issue with the gradient function

Open choudharyharsh122 opened this issue 9 months ago • 1 comments

I am working with Julia v1.6.7 and trying to execute this code:

W = rand(2, 5) b = rand(2) linear(x) = W * x .+ b grads = gradient(() -> sum(linear(x)), Params([W, b]))

but I receive the error:

MethodError: no method matching back!(::Float64) Closest candidates are: back!(::Any, ::Any; once) at C:\Users\choud.julia\packages\Tracker\tdXqL\src\back.jl:74 back!(::Tracker.TrackedReal; once) at C:\Users\choud.julia\packages\Tracker\tdXqL\src\lib\real.jl:15 back!(::Tracker.TrackedArray) at C:\Users\choud.julia\packages\Tracker\tdXqL\src\lib\array.jl:68

Stacktrace: [1] gradient_(f::var"#96#97", xs::Tracker.Params) @ Tracker C:\Users\choud.julia\packages\Tracker\tdXqL\src\back.jl:4 [2] gradient_(f::Function, ps::Params{Zygote.Buffer{Array{Float64, N} where N, Vector{Array{Float64, N} where N}}}) @ Zygote.ZygoteTrackerExt C:\Users\choud.julia\packages\Zygote\4SSHS\ext\ZygoteTrackerExt.jl:15 [3] #gradient#689 @ C:\Users\choud.julia\packages\Tracker\tdXqL\src\back.jl:164 [inlined] [4] gradient(f::Function, xs::Params{Zygote.Buffer{Array{Float64, N} where N, Vector{Array{Float64, N} where N}}}) @ Tracker C:\Users\choud.julia\packages\Tracker\tdXqL\src\back.jl:164 [5] top-level scope @ In[80]:4

Does this have to do anything with the version of my Julia

choudharyharsh122 avatar Sep 08 '23 09:09 choudharyharsh122