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

Incompatible with AbstractGPs.jl #180

Open
torfjelde opened this issue Jul 16, 2021 · 2 comments
Open

Incompatible with AbstractGPs.jl #180

torfjelde opened this issue Jul 16, 2021 · 2 comments

Comments

@torfjelde
Copy link
Member

AbstractGPs.jl has the following default implementation (https://github.com/JuliaGaussianProcesses/AbstractGPs.jl/blob/04e4c53a3a66c62c83cdb4f47aabcfb04543acf4/src/abstract_gp/finite_gp.jl#L298-L309):

function Distributions._logpdf(f::FiniteGP, y::AbstractVector{<:Real})
    return first(logpdf(f, reshape(y, :, 1)))
end
...
function Distributions.logpdf(f::FiniteGP, Y::AbstractMatrix{<:Real})
    m, C_mat = mean_and_cov(f)
    C = cholesky(_symmetric(C_mat))
    T = promote_type(eltype(m), eltype(C), eltype(Y))
    return -((size(Y, 1) * T(log(2π)) + logdet(C)) .+ diag_Xt_invA_X(C, Y .- m)) ./ 2
end

This means that

ZygoteRules.@adjoint function Distributions.logpdf(
dist::MultivariateDistribution,
X::AbstractMatrix{<:Real},
)
size(X, 1) == length(dist) ||
throw(DimensionMismatch("Inconsistent array dimensions."))
return ZygoteRules.pullback(dist, X) do dist, X
return map(i -> Distributions._logpdf(dist, view(X, :, i)), axes(X, 2))
end
end

will recursive indefinitively 😕

Should we maybe remove that the adjoint above? TBH it seems a bit too general.

@torfjelde
Copy link
Member Author

@mohamed82008
Copy link
Member

Try removing it, see if tests fail.

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