-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
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
Bug when using Matrix as differential for Adjoint #133
Comments
Oh god, no, that was most certainly not intentional. I'll take a look at this now. |
So I think that the problem is a fundamental one to do with how we compute the The current implementation is as follows: function _j′vp(fdm, f, ȳ::Vector{<:Real}, x::Vector{<:Real})
isempty(x) && return eltype(ȳ)[] # if x is empty, then so is the jacobian and x̄
return transpose(first(jacobian(fdm, f, x))) * ȳ
end where (crucially) Since julia> to_vec(ȳ_mat)[1]
6-element Array{Float64,1}:
0.6348048873881045
2.0834602173828207
-0.7874817791499601
0.33312169706657996
0.09073736368627416
-0.37933784525930764
julia> to_vec(ȳ_adjoint)[1]
6-element Array{Float64,1}:
0.6348048873881045
-2.0834602173828207
-0.7874817791499601
-0.33312169706657996
0.09073736368627416
0.37933784525930764 I think what's going wrong is clear from this -- the I think the temporary solution is pretty clear (revert to the old implementation with some reshaping), but I'm very confused about how to resolve this moving forward, and how it relates to the discussion in #132 . edit: I'm also not sure how to write tests to prevent this from happening in the future. |
I haven't checked the discussion in #132 , but I think |
#131 introduced a bug when differentials of
Adjoint
are regular matrices. Minimal example: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?The text was updated successfully, but these errors were encountered: