-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
AD issueProblem with automatic differentiationProblem with automatic differentiationbugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed
Description
Here is simplified view of the problem from @simsurace:
using Distributions
using Zygote
function DKL(par1, par2)
K1 = [par1[1] par1[2]; par1[2] par1[1]]
K2 = [par2[1] par2[2]; par2[2] par2[1]]
return kldivergence(
MvNormal(K1),
MvNormal(K2)
)
end
Zygote.gradient(par2 -> DKL([1., 0.1], par2), [1., 0.1])
With the following error:
ERROR: MethodError: no method matching +(::NamedTuple{(:dim, :mat, :chol), Tuple{Nothing, Nothing, NamedTuple{(:factors, :uplo, :info), Tuple{LinearAlgebra.Diagonal{Float64, Vector{Float64}}, Nothing, Nothing}}}}, ::Matrix{Float64})
Closest candidates are:
+(::Any, ::Any, ::Any, ::Any...) at ~/julia-1.7.1/share/julia/base/operators.jl:655
+(::FillArrays.Zeros{T, N}, ::AbstractArray{V, N}) where {T, V, N} at ~/.julia/packages/FillArrays/5Arin/src/fillalgebra.jl:228
+(::Tangent{P}, ::P) where P at ~/.julia/packages/ChainRulesCore/RbX5a/src/tangent_arithmetic.jl:146
...
Stacktrace:
[1] accum(x::NamedTuple{(:dim, :mat, :chol), Tuple{Nothing, Nothing, NamedTuple{(:factors, :uplo, :info), Tuple{LinearAlgebra.Diagonal{Float64, Vector{Float64}}, Nothing, Nothing}}}}, y::Matrix{Float64})
@ Zygote ~/.julia/packages/Zygote/ytjqm/src/lib/lib.jl:17
[2] macro expansion
@ ~/.julia/packages/Zygote/ytjqm/src/lib/lib.jl:27 [inlined]
[3] accum(x::NamedTuple{(:μ, :Σ), Tuple{Vector{Float64}, NamedTuple{(:dim, :mat, :chol), Tuple{Nothing, Nothing, NamedTuple{(:factors, :uplo, :info), Tuple{LinearAlgebra.Diagonal{Float64, Vector{Float64}}, Nothing, Nothing}}}}}}, y::NamedTuple{(:μ, :Σ), Tuple{Nothing, Matrix{Float64}}})
@ Zygote ~/.julia/packages/Zygote/ytjqm/src/lib/lib.jl:27
[4] accum(x::NamedTuple{(:μ, :Σ), Tuple{Nothing, NamedTuple{(:dim, :mat, :chol), Tuple{Nothing, Nothing, NamedTuple{(:factors, :uplo, :info), Tuple{LinearAlgebra.Diagonal{Float64, Vector{Float64}}, Nothing, Nothing}}}}}}, y::NamedTuple{(:μ, :Σ), Tuple{Vector{Float64}, Nothing}}, zs::NamedTuple{(:μ, :Σ), Tuple{Nothing, Matrix{Float64}}}) (repeats 2 times)
@ Zygote ~/.julia/packages/Zygote/ytjqm/src/lib/lib.jl:22
[5] Pullback
@ ~/.julia/packages/Distributions/O4ZJg/src/multivariate/mvnormal.jl:110 [inlined]
[6] (::typeof(∂(kldivergence)))(Δ::Float64)
@ Zygote ~/.julia/packages/Zygote/ytjqm/src/compiler/interface2.jl:0
[7] Pullback
@ ./REPL[16]:4 [inlined]
[8] (::typeof(∂(DKL)))(Δ::Float64)
@ Zygote ~/.julia/packages/Zygote/ytjqm/src/compiler/interface2.jl:0
[9] Pullback
@ ./REPL[18]:1 [inlined]
[10] (::typeof(∂(#5)))(Δ::Float64)
@ Zygote ~/.julia/packages/Zygote/ytjqm/src/compiler/interface2.jl:0
[11] (::Zygote.var"#56#57"{typeof(∂(#5))})(Δ::Float64)
@ Zygote ~/.julia/packages/Zygote/ytjqm/src/compiler/interface.jl:41
[12] gradient(f::Function, args::Vector{Float64})
@ Zygote ~/.julia/packages/Zygote/ytjqm/src/compiler/interface.jl:76
[13] top-level scope
@ REPL[18]:1
Metadata
Metadata
Assignees
Labels
AD issueProblem with automatic differentiationProblem with automatic differentiationbugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed