-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Add adjoints for functions on Hermitian matrices (take 2) #355
Conversation
The test is currently failing because DiffRule's complex derivative of |
Sure, please do. |
This reverts commit dbbf12f.
97b4471
to
29db72f
Compare
This reverts commit 54c1c4b.
1.0 doesn't have LinearAlgebra.RealHermSym
All of the functions considered here have the same domain as range.
Post-processing just enforces type constraints, but pulling back through it significantly changes gradients wrt args. It turns out this isn't necessary.
Enables overloading for specific functions
Separating real and imag makes gradients discontinuous when output type is determined by input value.
The |
When 2nd derivative is not available, use finite difference approximation of 2nd deriv for greater accuracy. When it is, relax the check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not amazingly well-equipped to review this / am currently overloaded to don't have time properly dive into this. That being said, from what I can tell fairly quickly it LGTM -- everything is tested as far as I can tell. As such, I don't want to hold this up, and I can't see any reason not to merge.
Since this is still marked WIP I'll give @sethaxen the ability to merge, rather than merging immediately. I'm not sure if any other help is needed from our side but lmk if so. bors d+ |
✌️ sethaxen can now approve this pull request. To approve and merge a pull request, simply reply with |
bors try |
tryMerge conflict |
@MikeInnes what's missing is this:
I'd appreciate feedback. I'd rather not merge something that fails the tests. |
Adding an adjoint for that case seems fine. We can remove it as part of #344 as needed, but that doesn't need to block this work. |
bors try |
tryBuild succeeded |
bors r+ |
355: [WIP] Add adjoints for functions on Hermitian matrices (take 2) r=sethaxen a=sethaxen _Note: this is a redo of #352 because of a wayward rebase_ This PR adds adjoints for the following functions of Hermitian and real symmetric matrices: - [x] `exp` - [x] `cos` - [x] `sin` - [x] `tan` - [x] `cosh` - [x] `sinh` - [x] `tanh` - [x] `log` - [x] `acos` - [x] `asin` - [x] `atan` - [x] `acosh` - [x] `asinh` - [x] `atanh` - [x] `sqrt` - [x] `sincos` - [x] `^` Each of these can be written as a matrix power series, which for a diagonalizable matrix simplifies to element-wise action of the function upon the eigenvalues of the matrix. Consequently, their computation in `LinearAlgebra` and their adjoints take a similar form to each other. Along the way, I fixed #340 for generic matrices, since the current adjoint for `exp` using the eigendecomposition shares a similar form to the Hermitian cases. Co-authored-by: Seth Axen <[email protected]>
Build succeeded |
Note: this is a redo of #352 because of a wayward rebase
This PR adds adjoints for the following functions of Hermitian and real symmetric matrices:
exp
cos
sin
tan
cosh
sinh
tanh
log
acos
asin
atan
acosh
asinh
atanh
sqrt
sincos
^
Each of these can be written as a matrix power series, which for a diagonalizable matrix simplifies to element-wise action of the function upon the eigenvalues of the matrix. Consequently, their computation in
LinearAlgebra
and their adjoints take a similar form to each other.Along the way, I fixed #340 for generic matrices, since the current adjoint for
exp
using the eigendecomposition shares a similar form to the Hermitian cases.