Here is a watered down version of code I am using
a = zeros(2393)
a = findall(x -> x == 0, a)
b = zeros(293)
e = rand(2979)
l = zeros(137,293)
g = ones(137,293)
h = rand(137,170)
function dummy(e::T...) where {T}
f = zeros(T,49810)
f[a] .= e[587:end]
f = reshape(f, 293, 170)
f = transpose(f)
c = zeros(T,137, 293)
m = 1.0./(1.0 .- (l * transpose(f)))
n = ((h.*m)*f).*g
d = b
for i in 1:137
for j in 1:293
c[i,j] = m[j]
d[j] = c[i,j]
end
end
end
ForwardDiff.gradient(e -> dummy(e...),e)
I get this error.
MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{var"#97#98", Float64}, Float64, 12})
Closest candidates are:
(::Type{T})(::Real, ::RoundingMode) where T<:AbstractFloat at rounding.jl:200
(::Type{T})(::T) where T<:Number at boot.jl:760
(::Type{T})(::AbstractChar) where T<:Union{AbstractChar, Number} at char.jl:50
...
Stacktrace:
[1] convert(#unused#::Type{Float64}, x::ForwardDiff.Dual{ForwardDiff.Tag{var"#97#98", Float64}, Float64, 12})
@ Base ./number.jl:7
[2] setindex!(A::Vector{Float64}, x::ForwardDiff.Dual{ForwardDiff.Tag{var"#97#98", Float64}, Float64, 12}, i1::Int64)
@ Base ./array.jl:839
[3] dummy(::ForwardDiff.Dual{ForwardDiff.Tag{var"#97#98", Float64}, Float64, 12}, ::Vararg{ForwardDiff.Dual{ForwardDiff.Tag{var"#97#98", Float64}, Float64, 12}, N} where N)
@ Main ./In[78]:38
[4] #97
@ ./In[79]:1 [inlined]
[5] chunk_mode_gradient(f::var"#97#98", x::Vector{Float64}, cfg::ForwardDiff.GradientConfig{ForwardDiff.Tag{var"#97#98", Float64}, Float64, 12, Vector{ForwardDiff.Dual{ForwardDiff.Tag{var"#97#98", Float64}, Float64, 12}}})
@ ForwardDiff ~/.julia/packages/ForwardDiff/QdStj/src/gradient.jl:150
[6] gradient(f::Function, x::Vector{Float64}, cfg::ForwardDiff.GradientConfig{ForwardDiff.Tag{var"#97#98", Float64}, Float64, 12, Vector{ForwardDiff.Dual{ForwardDiff.Tag{var"#97#98", Float64}, Float64, 12}}}, ::Val{true})
@ ForwardDiff ~/.julia/packages/ForwardDiff/QdStj/src/gradient.jl:21
[7] gradient(f::Function, x::Vector{Float64}, cfg::ForwardDiff.GradientConfig{ForwardDiff.Tag{var"#97#98", Float64}, Float64, 12, Vector{ForwardDiff.Dual{ForwardDiff.Tag{var"#97#98", Float64}, Float64, 12}}}) (repeats 2 times)
@ ForwardDiff ~/.julia/packages/ForwardDiff/QdStj/src/gradient.jl:17
[8] top-level scope
@ In[79]:1
[9] eval
@ ./boot.jl:360 [inlined]
[10] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1116
Line 38 is as follows:
d[j] = c[i,j]