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

Gradient of inv and logdet UpperTriangular matrix is not UpperTriangular #431

Closed
aterenin opened this issue Dec 19, 2019 · 1 comment · Fixed by #1044
Closed

Gradient of inv and logdet UpperTriangular matrix is not UpperTriangular #431

aterenin opened this issue Dec 19, 2019 · 1 comment · Fixed by #1044

Comments

@aterenin
Copy link
Contributor

For sparse Gaussian processes, one often wants to parametrize the variational distribution using its Cholesky factors, which form an upper-triangular matrix and are trainable.

However, when taking gradients, Zygote instead computes the gradient with respect to all entries in the UpperTriangular matrix, including ones that are set to zero by virtue of it being UpperTriangular. This is related to #163.

For the moment, a workaround suitable for training models is to simply call UpperTriangular(x) on the upper-triangular matrix x before using it.

@sdewaele
Copy link
Contributor

sdewaele commented Dec 21, 2019

Perhaps this is more related to #402. As an alternative you could insert the projection function ℙ in your code, see #402 (comment). Then, the adjoint will be an UpperTriangular. You would have to add the definition for the projection of the UpperTriangular:

(::Type{T},X) where {T<:UpperTriangular} = UpperTriangular(X)

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