I want to find the minimum of the curve it approximates using a simple gradient descent. It’s not to train the network. So yes. I could get that value using ReverseDiff.jl but I was hoping to use Flux to use the built-in optimizers.
nn = Dense(5,1)
static_input = [1.,2,3,4]
variable_input = param([5])
ps = Flux.Params(variable_input)
g = Flux.gradient(ps) do
sum(nn(vcat(static_input, variable_input)))
end
I think it does, g.grads is an IdDict of length 1 so It appears to have computed something like what I expect. But this is supposed to return the gradient I want isn’t it ?
>julia g[variable_input]
ERROR: KeyError: key Tracker.Tracked{Array{Float64,1}}(0x00000000, Tracker.Call{Nothing,Tuple{}}(nothing, ()), true, [0.8417484760284424]) not found
Stacktrace:
[1] getindex at ./abstractdict.jl:599 [inlined]
[2] getindex at /home/dehaybe/.julia/packages/Tracker/m6d46/src/params.jl:39 [inlined]
[3] getindex(::Tracker.Grads, ::TrackedArray{…,Array{Float64,1}}) at /home/dehaybe/.julia/packages/Tracker/m6d46/src/params.jl:43
[4] top-level scope at REPL[14]:1
Yes it does, thank you ! So to sum up, I had to use both param and Params and the inputs of Params should be arrays of tracked objects, not a tracked array.