Closed
Description
I am here to reporting some dubious results from the derivative of a matrix inversion for the diagonal matrix.
Package version: [f6369f11] ForwardDiff v0.10.14
A = [0.5 0 0 ; 0 0.5 0; 0 0 0.5]
ForwardDiff.gradient(A -> sum(inv(A)), A)
result:
3×3 Array{Float64,2}:
-4.0 -4.0 -4.0
0.0 -4.0 -4.0
0.0 0.0 -4.0
However, the analytical result should be:
-inv(A) * ones(3,3) * inv(A)
result:
3×3 Array{Float64,2}:
-4.0 -4.0 -4.0
-4.0 -4.0 -4.0
-4.0 -4.0 -4.0
The Zygote gradient function
Zygote.gradient(A -> sum(inv(A)), A)[1]
result:
3×3 Array{Float64,2}:
-4.0 -4.0 -4.0
-4.0 -4.0 -4.0
-4.0 -4.0 -4.0
Metadata
Metadata
Assignees
Labels
No labels