We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal example:
julia> using FiniteDifferences julia> using ChainRulesTestUtils: _fdm julia> j′vp(_fdm, x -> sum(x) > 1 ? zeros(10) : zeros(ComplexF64, 10), rand(10), zeros(10)) ERROR: DimensionMismatch("second dimension of A, 20, does not match length of x, 10") Stacktrace: [1] gemv!(y::Vector{Float64}, tA::Char, A::Matrix{Float64}, x::Vector{Float64}, α::Bool, β::Bool) @ LinearAlgebra /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.8/LinearAlgebra/src/matmul.jl:530 [2] mul! @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.8/LinearAlgebra/src/matmul.jl:97 [inlined] [3] mul! @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.8/LinearAlgebra/src/matmul.jl:275 [inlined] [4] *(transA::LinearAlgebra.Transpose{Float64, Matrix{Float64}}, x::Vector{Float64}) @ LinearAlgebra /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.8/LinearAlgebra/src/matmul.jl:87 [5] _j′vp(fdm::FiniteDifferences.AdaptedFiniteDifferenceMethod{5, 1, FiniteDifferences.UnadaptedFiniteDifferenceMethod{7, 5}}, f::Function, ȳ::Vector{Float64}, x::Vector{Float64}) @ FiniteDifferences ~/.julia/dev/FiniteDifferences/src/grad.jl:80 [6] j′vp(fdm::FiniteDifferences.AdaptedFiniteDifferenceMethod{5, 1, FiniteDifferences.UnadaptedFiniteDifferenceMethod{7, 5}}, f::Function, ȳ::Vector{Float64}, x::Vector{Float64}) @ FiniteDifferences ~/.julia/dev/FiniteDifferences/src/grad.jl:73 [7] top-level scope @ REPL[10]:1
The issue here is that jacobian assumes that to_vec(f(x)) is always the same size if x is perturbed, which fails if f(x) can sometimes be real and sometimes complex. This does occur in the real world, in my case it was with eigen(M).vectors (ref https://github.com/JuliaDiff/ChainRules.jl/blob/8ce21af2c8f8fa5dad4b1d5aaac32c7847ed1b9f/test/rulesets/LinearAlgebra/factorization.jl#L214). It might be enough to just throw a better error message here suggesting to convert the output of f to complex numbers.
jacobian
to_vec(f(x))
x
f(x)
eigen(M).vectors
f
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Minimal example:
The issue here is that
jacobian
assumes thatto_vec(f(x))
is always the same size ifx
is perturbed, which fails iff(x)
can sometimes be real and sometimes complex. This does occur in the real world, in my case it was witheigen(M).vectors
(ref https://github.com/JuliaDiff/ChainRules.jl/blob/8ce21af2c8f8fa5dad4b1d5aaac32c7847ed1b9f/test/rulesets/LinearAlgebra/factorization.jl#L214). It might be enough to just throw a better error message here suggesting to convert the output off
to complex numbers.The text was updated successfully, but these errors were encountered: