Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with the gradient function #163

Open
choudharyharsh122 opened this issue Sep 8, 2023 · 1 comment
Open

Issue with the gradient function #163

choudharyharsh122 opened this issue Sep 8, 2023 · 1 comment

Comments

@choudharyharsh122
Copy link

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

@ToucheSir
Copy link
Member

Can you please provide a full Minimal Working Example (MWE) which has all required code to run? Currently this one lacks any package imports, and I can't even tell if you're using Zygote!

@mcabbott mcabbott transferred this issue from FluxML/Zygote.jl Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants