Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Help with Zygote and parameters

$
0
0

I’m having a hard time figuring out why this works:

using Zygote
W, b = rand(2, 3), rand(2)
predict(x) = W*x .+ b
g = gradient(() -> sum(predict([1,2,3])), Params([W, b]))
g[W], g[b]

but this doesn’t:

using Zygote
a = 2
x = 2
f(x) = x^a
gp = gradient(() -> f(x), Params(a))
gp[a]

I get the error:

ERROR: Only reference types can be differentiated with `Params`.

Can anyone help?

7 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles