-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Description
#131 introduced a bug when differentials of Adjoint
are regular matrices. Minimal example:
julia> using FiniteDifferences, LinearAlgebra
julia> n, T = 3, ComplexF64;
julia> x = randn(T, n);
julia> y = adjoint(x);
julia> ȳ_adjoint = adjoint(randn(T, n))
1×3 adjoint(::Vector{ComplexF64}) with eltype ComplexF64:
-0.0351965+0.649028im 0.868707+0.237612im -1.45535-0.149933im
julia> ȳ_mat = collect(ȳ_adjoint);
julia> ȳ_composite = FiniteDifferences.Composite{typeof(y)}(parent=parent(ȳ_adjoint));
julia> ȳ_adjoint' # expected
3-element Vector{ComplexF64}:
-0.03519650654436998 - 0.6490275763507989im
0.8687071179992576 - 0.23761165442658064im
-1.4553505347699434 + 0.14993263689809244im
julia> j′vp(central_fdm(5, 1), adjoint, ȳ_adjoint, x)[1] # fine
3-element Vector{ComplexF64}:
-0.035196506544367144 - 0.6490275763508034im
0.8687071179992422 - 0.2376116544265735im
-1.4553505347699498 + 0.14993263689809289im
julia> j′vp(central_fdm(5, 1), adjoint, ȳ_composite, x)[1] # fine
3-element Vector{ComplexF64}:
-0.035196506544367144 - 0.6490275763508034im
0.8687071179992422 - 0.2376116544265735im
-1.4553505347699498 + 0.14993263689809289im
julia> j′vp(central_fdm(5, 1), adjoint, ȳ_mat, x)[1] # conjugated
3-element Vector{ComplexF64}:
-0.03519650654436785 + 0.6490275763508094im
0.868707117999241 + 0.23761165442657906im
-1.4553505347699507 - 0.1499326368980859im
I've stared at the PR but can't figure out where it went wrong. Or maybe the issue is that a regular matrix is not an acceptable cotangent for an Adjoint
. This was caught by the ChainRules test suite.
@willtebbutt I also noticed that PR disabled testing of to_vec
for many complex types. Was that intentional?
Metadata
Metadata
Assignees
Labels
No labels