Skip to content
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

wrong derivative with array concatenation #145

Open
andrewning opened this issue Sep 3, 2020 · 1 comment
Open

wrong derivative with array concatenation #145

andrewning opened this issue Sep 3, 2020 · 1 comment

Comments

@andrewning
Copy link

My code used to work in ReverseDiff 1.2.0 but the current version (1.4.2) returns the wrong derivatives. I've stripped away everything to a MWE:

import ForwardDiff
import ReverseDiff

struct Test{TF}
    a::TF
end

function func(x)
    tvec = Test.(x[1:2])
    a = [t.a for t in tvec]
    return sum([a; x[3]])
end

x = [1.0, 2.0, 3.0]
J1 = ForwardDiff.gradient(func, x)
J2 = ReverseDiff.gradient(func, x)

The answer should be [1, 1, 1], but ReverseDiff gives [0, 0, 1]. If I revert back to 1.2 then it works as expected. Trying different versions it seems that from 1.3 onward this no longer works.

@mohamed82008
Copy link
Member

I think I know what's happening here. I will work on a fix soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants