-
-
Couldn't load subscription status.
- Fork 216
Open
Description
MWE:
using Zygote
using LinearAlgebra
D = (Diagonal(ones(3)))
V = ones(3)
function f(x)
return V'*D*V + ((V - x)'D*(V - x))
end
gradient(f, V)
gives the error message
MethodError: no method matching +(::LinearAlgebra.Diagonal{Float64, Vector{Float64}}, ::@NamedTuple{diag::Vector{Float64}})
The function `+` exists, but no method is defined for this combination of argument types.
The error is thrown when accumulating from the two occurences of D in f(x). No error is thrown if one occurence is removed. The error can also be removed by adding collect(D) or parantheses around the multiplications to turn them into two binary multiplications.
If I insert @showgrad(D), it shows that the gradient w.r.t. D is a NamedTuple and not a Diagonal.
Metadata
Metadata
Assignees
Labels
No labels