Skip to content

Issue with the gradient function #163

Open
@choudharyharsh122

Description

@choudharyharsh122

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions