julia> using Arpack
julia> function f(x)
val, vec = eigs( x; nev = 1, which = :LM, maxiter = 300 )
return log(real(val[1]))
end
f (generic function with 1 method)
julia> x0 = rand(4,4)
4×4 Matrix{Float64}:
0.817398 0.922428 0.819335 0.940888
0.0612446 0.514584 0.979874 0.496911
0.936561 0.282771 0.659465 0.618731
0.207618 0.304318 0.504621 0.247501
julia>
julia> using Zygote
julia> gradient(f,x0)
ERROR: Compiling Tuple{Arpack.var"##_eigs#17", Int64, Int64, Symbol, Float64, Int64, Nothing, Vector{Float64}, Bool, Symbol, Int64, typeof(Arpack._eigs), Matrix{Float64}, LinearAlgebra.UniformScaling{Bool}}: try/catch is not supported.
Refer to the Zygote documentation for fixes.
https://fluxml.ai/Zygote.jl/latest/limitations
I only need the largest eigenvalue of a matrix in my calculation, so I call the eig() function, but it doesn’t seem to support zygote.