-
Notifications
You must be signed in to change notification settings - Fork 21
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
Sign in adjoint derivative calculation #35
Comments
Good question! The minus sign makes its way to this line: Line 352 in 83080bc
Because otherwise it would be
Sorry that it's a bit confusing. We should probably just move it up to the solve line. This minus sign was certainly a pain for us when we were initially debugging. |
I've included some example code (test_diffcp_vjp.txt), where I've just copied in
There seems to be a difference in sign. Am I computing |
I've been following the paper "Differentiating Through a Cone Program" and the code side-by-side, and I'm having trouble figuring out if there is a sign error in the adjoint derivative code or if I've misunderstood something.
diffcp/diffcp/cone_program.py
Lines 341 to 357 in 83080bc
It seems like, when compared to the paper, the code solves
M.T @ r = dz
forr
, whereas the paper solvesM.T @ g = -dz
forg
. Sor = -g
. But then the equations used in the code to compute(dA, db, dc)
seem to match those in the paper, when they should all differ by a negative sign.Similarly, for the forward-mode derivative, you solve
M @ dz = dQ @ pi_z
fordz
, use the same equations as in the paper despite the sign difference, but you multiply(dx, dy, dz)
by-1
before returning, so this is fine.Is this a sign error in the adjoint derivative, or did I get something wrong?
The text was updated successfully, but these errors were encountered: